Query Parser Module Refactor, closes #994.
This commit is contained in:
parent
58330d9c23
commit
0a4e582404
|
@ -43,7 +43,7 @@ import org.elasticsearch.threadpool.ThreadPoolModule;
|
|||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import static org.elasticsearch.index.query.xcontent.QueryBuilders.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
|
|
|
@ -33,7 +33,7 @@ import static org.elasticsearch.client.Requests.*;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.*;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.*;
|
||||
import static org.elasticsearch.index.query.xcontent.QueryBuilders.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.elasticsearch.node.NodeBuilder.*;
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,7 +39,7 @@ import static org.elasticsearch.client.Requests.*;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.*;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.*;
|
||||
import static org.elasticsearch.index.query.xcontent.QueryBuilders.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.elasticsearch.node.NodeBuilder.*;
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,7 @@ import static org.elasticsearch.client.Requests.*;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.*;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.*;
|
||||
import static org.elasticsearch.index.query.xcontent.QueryBuilders.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.elasticsearch.node.NodeBuilder.*;
|
||||
import static org.elasticsearch.search.facet.FacetBuilders.*;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ import static org.elasticsearch.client.Requests.*;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.*;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.*;
|
||||
import static org.elasticsearch.index.query.xcontent.QueryBuilders.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.elasticsearch.node.NodeBuilder.*;
|
||||
|
||||
public class QueryFilterFacetSearchBenchmark {
|
||||
|
|
|
@ -42,7 +42,7 @@ import static org.elasticsearch.client.Requests.*;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.*;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.*;
|
||||
import static org.elasticsearch.index.query.xcontent.QueryBuilders.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.elasticsearch.node.NodeBuilder.*;
|
||||
import static org.elasticsearch.search.facet.FacetBuilders.*;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.elasticsearch.common.StopWatch;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.query.xcontent.XContentQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.node.Node;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
@ -37,8 +37,8 @@ import static org.elasticsearch.client.Requests.*;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.*;
|
||||
import static org.elasticsearch.index.query.xcontent.FilterBuilders.*;
|
||||
import static org.elasticsearch.index.query.xcontent.QueryBuilders.*;
|
||||
import static org.elasticsearch.index.query.FilterBuilders.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.elasticsearch.node.NodeBuilder.*;
|
||||
import static org.elasticsearch.search.builder.SearchSourceBuilder.*;
|
||||
|
||||
|
@ -203,7 +203,7 @@ public class NodesStressTest {
|
|||
barrier2.await();
|
||||
for (; counter < max; counter++) {
|
||||
Client client = client(counter);
|
||||
XContentQueryBuilder query = termQuery("num", counter % fieldNumLimit);
|
||||
QueryBuilder query = termQuery("num", counter % fieldNumLimit);
|
||||
query = constantScoreQuery(queryFilter(query));
|
||||
|
||||
SearchResponse search = client.search(searchRequest()
|
||||
|
@ -245,8 +245,8 @@ public class NodesStressTest {
|
|||
long id = idGenerator.incrementAndGet();
|
||||
client.index(Requests.indexRequest().index("test").type("type1").id(Long.toString(id))
|
||||
.source(XContentFactory.jsonBuilder().startObject()
|
||||
.field("num", id % fieldNumLimit)
|
||||
.endObject()))
|
||||
.field("num", id % fieldNumLimit)
|
||||
.endObject()))
|
||||
.actionGet();
|
||||
}
|
||||
System.out.println("Indexer [" + id + "]: Done");
|
||||
|
|
|
@ -37,7 +37,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.*;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.*;
|
||||
import static org.elasticsearch.index.query.xcontent.QueryBuilders.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.elasticsearch.node.NodeBuilder.*;
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,7 +32,7 @@ import static org.elasticsearch.client.Requests.*;
|
|||
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.*;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.*;
|
||||
import static org.elasticsearch.index.query.xcontent.QueryBuilders.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.elasticsearch.node.NodeBuilder.*;
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.lucene.search.Filter;
|
|||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermRangeFilter;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.query.xcontent.QueryParseContext;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
||||
import static org.elasticsearch.index.query.support.QueryParsers.*;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package org.apache.lucene.queryParser;
|
||||
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.index.query.xcontent.QueryParseContext;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.elasticsearch.index.mapper.AllFieldMapper;
|
|||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.mapper.FieldMappers;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.query.xcontent.QueryParseContext;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.lucene.search.Query;
|
|||
import org.apache.lucene.search.TermRangeFilter;
|
||||
import org.elasticsearch.common.lucene.search.NotFilter;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.query.xcontent.QueryParseContext;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
||||
import static org.elasticsearch.index.query.support.QueryParsers.*;
|
||||
|
||||
|
|
|
@ -19,8 +19,12 @@
|
|||
|
||||
package org.apache.lucene.queryParser;
|
||||
|
||||
import org.apache.lucene.search.*;
|
||||
import org.elasticsearch.index.query.xcontent.QueryParseContext;
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.DisjunctionMaxQuery;
|
||||
import org.apache.lucene.search.MultiPhraseQuery;
|
||||
import org.apache.lucene.search.PhraseQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.elasticsearch.common.xcontent.ToXContent;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.query.xcontent.XContentFilterBuilder;
|
||||
import org.elasticsearch.index.query.FilterBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
@ -104,7 +104,7 @@ public class IndicesAliasesRequest extends MasterNodeOperationRequest {
|
|||
* @param alias The alias
|
||||
* @param filterBuilder The filter
|
||||
*/
|
||||
public IndicesAliasesRequest addAlias(String index, String alias, XContentFilterBuilder filterBuilder) {
|
||||
public IndicesAliasesRequest addAlias(String index, String alias, FilterBuilder filterBuilder) {
|
||||
if (filterBuilder == null) {
|
||||
aliasActions.add(new AliasAction(AliasAction.Type.ADD, index, alias));
|
||||
return this;
|
||||
|
|
|
@ -35,8 +35,8 @@ import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
|||
import org.elasticsearch.cluster.metadata.MetaDataMappingService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.query.xcontent.FilterBuilders;
|
||||
import org.elasticsearch.index.query.xcontent.QueryBuilders;
|
||||
import org.elasticsearch.index.query.FilterBuilders;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
|
|
|
@ -71,7 +71,6 @@ public class CountRequest extends BroadcastOperationRequest {
|
|||
private boolean querySourceUnsafe;
|
||||
|
||||
private String[] types = Strings.EMPTY_ARRAY;
|
||||
private String queryParserName;
|
||||
|
||||
CountRequest() {
|
||||
}
|
||||
|
@ -168,7 +167,7 @@ public class CountRequest extends BroadcastOperationRequest {
|
|||
/**
|
||||
* The query source to execute.
|
||||
*
|
||||
* @see org.elasticsearch.index.query.xcontent.QueryBuilders
|
||||
* @see org.elasticsearch.index.query.QueryBuilders
|
||||
*/
|
||||
@Required public CountRequest query(QueryBuilder queryBuilder) {
|
||||
BytesStream bos = queryBuilder.buildAsUnsafeBytes();
|
||||
|
@ -235,21 +234,6 @@ public class CountRequest extends BroadcastOperationRequest {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The query parse name to use. If not set, will use the default one.
|
||||
*/
|
||||
String queryParserName() {
|
||||
return queryParserName;
|
||||
}
|
||||
|
||||
/**
|
||||
* The query parse name to use. If not set, will use the default one.
|
||||
*/
|
||||
public CountRequest queryParserName(String queryParserName) {
|
||||
this.queryParserName = queryParserName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The types of documents the query will run against. Defaults to all types.
|
||||
*/
|
||||
|
@ -305,9 +289,6 @@ public class CountRequest extends BroadcastOperationRequest {
|
|||
querySource = new byte[querySourceLength];
|
||||
in.readFully(querySource);
|
||||
|
||||
if (in.readBoolean()) {
|
||||
queryParserName = in.readUTF();
|
||||
}
|
||||
int typesSize = in.readVInt();
|
||||
if (typesSize > 0) {
|
||||
types = new String[typesSize];
|
||||
|
@ -337,12 +318,6 @@ public class CountRequest extends BroadcastOperationRequest {
|
|||
out.writeVInt(querySourceLength);
|
||||
out.writeBytes(querySource, querySourceOffset, querySourceLength);
|
||||
|
||||
if (queryParserName == null) {
|
||||
out.writeBoolean(false);
|
||||
} else {
|
||||
out.writeBoolean(true);
|
||||
out.writeUTF(queryParserName);
|
||||
}
|
||||
out.writeVInt(types.length);
|
||||
for (String type : types) {
|
||||
out.writeUTF(type);
|
||||
|
|
|
@ -41,7 +41,6 @@ class ShardCountRequest extends BroadcastShardOperationRequest {
|
|||
private int querySourceLength;
|
||||
|
||||
private String[] types = Strings.EMPTY_ARRAY;
|
||||
@Nullable private String queryParserName;
|
||||
|
||||
@Nullable private String[] filteringAliases;
|
||||
|
||||
|
@ -55,7 +54,6 @@ class ShardCountRequest extends BroadcastShardOperationRequest {
|
|||
this.querySource = request.querySource();
|
||||
this.querySourceOffset = request.querySourceOffset();
|
||||
this.querySourceLength = request.querySourceLength();
|
||||
this.queryParserName = request.queryParserName();
|
||||
this.types = request.types();
|
||||
this.filteringAliases = filteringAliases;
|
||||
}
|
||||
|
@ -76,10 +74,6 @@ class ShardCountRequest extends BroadcastShardOperationRequest {
|
|||
return querySourceLength;
|
||||
}
|
||||
|
||||
public String queryParserName() {
|
||||
return queryParserName;
|
||||
}
|
||||
|
||||
public String[] types() {
|
||||
return this.types;
|
||||
}
|
||||
|
@ -95,9 +89,6 @@ class ShardCountRequest extends BroadcastShardOperationRequest {
|
|||
querySourceOffset = 0;
|
||||
querySource = new byte[querySourceLength];
|
||||
in.readFully(querySource);
|
||||
if (in.readBoolean()) {
|
||||
queryParserName = in.readUTF();
|
||||
}
|
||||
int typesSize = in.readVInt();
|
||||
if (typesSize > 0) {
|
||||
types = new String[typesSize];
|
||||
|
@ -119,12 +110,6 @@ class ShardCountRequest extends BroadcastShardOperationRequest {
|
|||
out.writeFloat(minScore);
|
||||
out.writeVInt(querySourceLength);
|
||||
out.writeBytes(querySource, querySourceOffset, querySourceLength);
|
||||
if (queryParserName == null) {
|
||||
out.writeBoolean(false);
|
||||
} else {
|
||||
out.writeBoolean(true);
|
||||
out.writeUTF(queryParserName);
|
||||
}
|
||||
out.writeVInt(types.length);
|
||||
for (String type : types) {
|
||||
out.writeUTF(type);
|
||||
|
|
|
@ -119,7 +119,7 @@ public class TransportCountAction extends TransportBroadcastOperationAction<Coun
|
|||
@Override protected ShardCountResponse shardOperation(ShardCountRequest request) throws ElasticSearchException {
|
||||
IndexShard indexShard = indicesService.indexServiceSafe(request.index()).shardSafe(request.shardId());
|
||||
long count = indexShard.count(request.minScore(), request.querySource(), request.querySourceOffset(), request.querySourceLength(),
|
||||
request.queryParserName(), request.filteringAliases(), request.types());
|
||||
request.filteringAliases(), request.types());
|
||||
return new ShardCountResponse(request.index(), request.shardId(), count);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,6 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest {
|
|||
private int querySourceLength;
|
||||
private boolean querySourceUnsafe;
|
||||
|
||||
private String queryParserName;
|
||||
private String[] types = Strings.EMPTY_ARRAY;
|
||||
@Nullable private String routing;
|
||||
|
||||
|
@ -120,7 +119,7 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest {
|
|||
/**
|
||||
* The query source to execute.
|
||||
*
|
||||
* @see org.elasticsearch.index.query.xcontent.QueryBuilders
|
||||
* @see org.elasticsearch.index.query.QueryBuilders
|
||||
*/
|
||||
@Required public DeleteByQueryRequest query(QueryBuilder queryBuilder) {
|
||||
BytesStream bos = queryBuilder.buildAsUnsafeBytes();
|
||||
|
@ -187,21 +186,6 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The query parse name to use. If not set, will use the default one.
|
||||
*/
|
||||
String queryParserName() {
|
||||
return queryParserName;
|
||||
}
|
||||
|
||||
/**
|
||||
* The query parse name to use. If not set, will use the default one.
|
||||
*/
|
||||
public DeleteByQueryRequest queryParserName(String queryParserName) {
|
||||
this.queryParserName = queryParserName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The types of documents the query will run against. Defaults to all types.
|
||||
*/
|
||||
|
@ -286,10 +270,6 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest {
|
|||
querySource = new byte[querySourceLength];
|
||||
in.readFully(querySource);
|
||||
|
||||
if (in.readBoolean()) {
|
||||
queryParserName = in.readUTF();
|
||||
}
|
||||
|
||||
if (in.readBoolean()) {
|
||||
routing = in.readUTF();
|
||||
}
|
||||
|
@ -311,12 +291,6 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest {
|
|||
out.writeVInt(querySourceLength);
|
||||
out.writeBytes(querySource, querySourceOffset, querySourceLength);
|
||||
|
||||
if (queryParserName == null) {
|
||||
out.writeBoolean(false);
|
||||
} else {
|
||||
out.writeBoolean(true);
|
||||
out.writeUTF(queryParserName);
|
||||
}
|
||||
if (routing == null) {
|
||||
out.writeBoolean(false);
|
||||
} else {
|
||||
|
|
|
@ -41,7 +41,6 @@ import static org.elasticsearch.action.Actions.*;
|
|||
public class IndexDeleteByQueryRequest extends IndexReplicationOperationRequest {
|
||||
|
||||
private byte[] querySource;
|
||||
private String queryParserName;
|
||||
private String[] types = Strings.EMPTY_ARRAY;
|
||||
@Nullable private String routing;
|
||||
@Nullable private String[] filteringAliases;
|
||||
|
@ -50,7 +49,6 @@ public class IndexDeleteByQueryRequest extends IndexReplicationOperationRequest
|
|||
this.index = index;
|
||||
this.timeout = request.timeout();
|
||||
this.querySource = request.querySource();
|
||||
this.queryParserName = request.queryParserName();
|
||||
this.types = request.types();
|
||||
this.replicationType = request.replicationType();
|
||||
this.consistencyLevel = request.consistencyLevel();
|
||||
|
@ -82,10 +80,6 @@ public class IndexDeleteByQueryRequest extends IndexReplicationOperationRequest
|
|||
return this;
|
||||
}
|
||||
|
||||
String queryParserName() {
|
||||
return queryParserName;
|
||||
}
|
||||
|
||||
String routing() {
|
||||
return this.routing;
|
||||
}
|
||||
|
@ -98,11 +92,6 @@ public class IndexDeleteByQueryRequest extends IndexReplicationOperationRequest
|
|||
return filteringAliases;
|
||||
}
|
||||
|
||||
public IndexDeleteByQueryRequest queryParserName(String queryParserName) {
|
||||
this.queryParserName = queryParserName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IndexDeleteByQueryRequest timeout(TimeValue timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
|
@ -112,9 +101,6 @@ public class IndexDeleteByQueryRequest extends IndexReplicationOperationRequest
|
|||
super.readFrom(in);
|
||||
querySource = new byte[in.readVInt()];
|
||||
in.readFully(querySource);
|
||||
if (in.readBoolean()) {
|
||||
queryParserName = in.readUTF();
|
||||
}
|
||||
int typesSize = in.readVInt();
|
||||
if (typesSize > 0) {
|
||||
types = new String[typesSize];
|
||||
|
@ -138,12 +124,6 @@ public class IndexDeleteByQueryRequest extends IndexReplicationOperationRequest
|
|||
super.writeTo(out);
|
||||
out.writeVInt(querySource.length);
|
||||
out.writeBytes(querySource);
|
||||
if (queryParserName == null) {
|
||||
out.writeBoolean(false);
|
||||
} else {
|
||||
out.writeBoolean(true);
|
||||
out.writeUTF(queryParserName);
|
||||
}
|
||||
out.writeVInt(types.length);
|
||||
for (String type : types) {
|
||||
out.writeUTF(type);
|
||||
|
|
|
@ -41,7 +41,6 @@ public class ShardDeleteByQueryRequest extends ShardReplicationOperationRequest
|
|||
|
||||
private int shardId;
|
||||
private byte[] querySource;
|
||||
private String queryParserName;
|
||||
private String[] types = Strings.EMPTY_ARRAY;
|
||||
@Nullable private String routing;
|
||||
@Nullable private String[] filteringAliases;
|
||||
|
@ -49,7 +48,6 @@ public class ShardDeleteByQueryRequest extends ShardReplicationOperationRequest
|
|||
ShardDeleteByQueryRequest(IndexDeleteByQueryRequest request, int shardId) {
|
||||
this.index = request.index();
|
||||
this.querySource = request.querySource();
|
||||
this.queryParserName = request.queryParserName();
|
||||
this.types = request.types();
|
||||
this.shardId = shardId;
|
||||
replicationType(request.replicationType());
|
||||
|
@ -78,10 +76,6 @@ public class ShardDeleteByQueryRequest extends ShardReplicationOperationRequest
|
|||
return querySource;
|
||||
}
|
||||
|
||||
public String queryParserName() {
|
||||
return queryParserName;
|
||||
}
|
||||
|
||||
public String[] types() {
|
||||
return this.types;
|
||||
}
|
||||
|
@ -98,9 +92,6 @@ public class ShardDeleteByQueryRequest extends ShardReplicationOperationRequest
|
|||
super.readFrom(in);
|
||||
querySource = new byte[in.readVInt()];
|
||||
in.readFully(querySource);
|
||||
if (in.readBoolean()) {
|
||||
queryParserName = in.readUTF();
|
||||
}
|
||||
shardId = in.readVInt();
|
||||
int typesSize = in.readVInt();
|
||||
if (typesSize > 0) {
|
||||
|
@ -125,12 +116,6 @@ public class ShardDeleteByQueryRequest extends ShardReplicationOperationRequest
|
|||
super.writeTo(out);
|
||||
out.writeVInt(querySource.length);
|
||||
out.writeBytes(querySource);
|
||||
if (queryParserName == null) {
|
||||
out.writeBoolean(false);
|
||||
} else {
|
||||
out.writeBoolean(true);
|
||||
out.writeUTF(queryParserName);
|
||||
}
|
||||
out.writeVInt(shardId);
|
||||
out.writeVInt(types.length);
|
||||
for (String type : types) {
|
||||
|
|
|
@ -70,13 +70,13 @@ public class TransportShardDeleteByQueryAction extends TransportShardReplication
|
|||
|
||||
@Override protected PrimaryResponse<ShardDeleteByQueryResponse> shardOperationOnPrimary(ClusterState clusterState, ShardOperationRequest shardRequest) {
|
||||
ShardDeleteByQueryRequest request = shardRequest.request;
|
||||
indexShard(shardRequest).deleteByQuery(request.querySource(), request.queryParserName(), request.filteringAliases(), request.types());
|
||||
indexShard(shardRequest).deleteByQuery(request.querySource(), request.filteringAliases(), request.types());
|
||||
return new PrimaryResponse<ShardDeleteByQueryResponse>(new ShardDeleteByQueryResponse(), null);
|
||||
}
|
||||
|
||||
@Override protected void shardOperationOnReplica(ShardOperationRequest shardRequest) {
|
||||
ShardDeleteByQueryRequest request = shardRequest.request;
|
||||
indexShard(shardRequest).deleteByQuery(request.querySource(), request.queryParserName(), request.filteringAliases(), request.types());
|
||||
indexShard(shardRequest).deleteByQuery(request.querySource(), request.filteringAliases(), request.types());
|
||||
}
|
||||
|
||||
@Override protected ShardIterator shards(ClusterState clusterState, ShardDeleteByQueryRequest request) {
|
||||
|
|
|
@ -36,9 +36,14 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.query.xcontent.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.xcontent.MoreLikeThisFieldQueryBuilder;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.mapper.FieldMappers;
|
||||
import org.elasticsearch.index.mapper.InternalMapper;
|
||||
import org.elasticsearch.index.mapper.SourceFieldMapper;
|
||||
import org.elasticsearch.index.mapper.SourceToParse;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.MoreLikeThisFieldQueryBuilder;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.BaseTransportRequestHandler;
|
||||
|
@ -51,7 +56,7 @@ import java.util.Set;
|
|||
|
||||
import static org.elasticsearch.client.Requests.*;
|
||||
import static org.elasticsearch.common.collect.Sets.*;
|
||||
import static org.elasticsearch.index.query.xcontent.QueryBuilders.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.elasticsearch.search.builder.SearchSourceBuilder.*;
|
||||
|
||||
/**
|
||||
|
|
|
@ -107,7 +107,7 @@ public class Requests {
|
|||
|
||||
/**
|
||||
* Creates a delete by query request. Note, the query itself must be set either by setting the JSON source
|
||||
* of the query, or by using a {@link org.elasticsearch.index.query.QueryBuilder} (using {@link org.elasticsearch.index.query.xcontent.QueryBuilders}).
|
||||
* of the query, or by using a {@link org.elasticsearch.index.query.QueryBuilder} (using {@link org.elasticsearch.index.query.QueryBuilders}).
|
||||
*
|
||||
* @param indices The indices the delete by query against. Use <tt>null</tt> or <tt>_all</tt> to execute against all indices
|
||||
* @return The delete by query request
|
||||
|
@ -131,7 +131,7 @@ public class Requests {
|
|||
|
||||
/**
|
||||
* Creates a count request which counts the hits matched against a query. Note, the query itself must be set
|
||||
* either using the JSON source of the query, or using a {@link org.elasticsearch.index.query.QueryBuilder} (using {@link org.elasticsearch.index.query.xcontent.QueryBuilders}).
|
||||
* either using the JSON source of the query, or using a {@link org.elasticsearch.index.query.QueryBuilder} (using {@link org.elasticsearch.index.query.QueryBuilders}).
|
||||
*
|
||||
* @param indices The indices to count matched documents against a query. Use <tt>null</tt> or <tt>_all</tt> to execute against all indices
|
||||
* @return The count request
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
|
|||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.index.query.xcontent.XContentFilterBuilder;
|
||||
import org.elasticsearch.index.query.FilterBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -76,11 +76,11 @@ public class IndicesAliasesRequestBuilder extends BaseIndicesRequestBuilder<Indi
|
|||
/**
|
||||
* Adds an alias to the index.
|
||||
*
|
||||
* @param index The index
|
||||
* @param alias The alias
|
||||
* @param index The index
|
||||
* @param alias The alias
|
||||
* @param filterBuilder The filter
|
||||
*/
|
||||
public IndicesAliasesRequestBuilder addAlias(String index, String alias, XContentFilterBuilder filterBuilder) {
|
||||
public IndicesAliasesRequestBuilder addAlias(String index, String alias, FilterBuilder filterBuilder) {
|
||||
request.addAlias(index, alias, filterBuilder);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -54,14 +54,6 @@ public class CountRequestBuilder extends BaseRequestBuilder<CountRequest, CountR
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The query parse name to use. If not set, will use the default one.
|
||||
*/
|
||||
public CountRequestBuilder setQueryParserName(String queryParserName) {
|
||||
request.queryParserName(queryParserName);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The minimum score of the documents to include in the count. Defaults to <tt>-1</tt> which means all
|
||||
* documents will be included in the count.
|
||||
|
@ -98,7 +90,7 @@ public class CountRequestBuilder extends BaseRequestBuilder<CountRequest, CountR
|
|||
/**
|
||||
* The query source to execute.
|
||||
*
|
||||
* @see org.elasticsearch.index.query.xcontent.QueryBuilders
|
||||
* @see org.elasticsearch.index.query.QueryBuilders
|
||||
*/
|
||||
public CountRequestBuilder setQuery(QueryBuilder queryBuilder) {
|
||||
request.query(queryBuilder);
|
||||
|
@ -108,7 +100,7 @@ public class CountRequestBuilder extends BaseRequestBuilder<CountRequest, CountR
|
|||
/**
|
||||
* The query source to execute.
|
||||
*
|
||||
* @see org.elasticsearch.index.query.xcontent.QueryBuilders
|
||||
* @see org.elasticsearch.index.query.QueryBuilders
|
||||
*/
|
||||
public CountRequestBuilder setQuery(byte[] querySource) {
|
||||
request.query(querySource);
|
||||
|
|
|
@ -77,7 +77,7 @@ public class DeleteByQueryRequestBuilder extends BaseRequestBuilder<DeleteByQuer
|
|||
/**
|
||||
* The query source to execute.
|
||||
*
|
||||
* @see org.elasticsearch.index.query.xcontent.QueryBuilders
|
||||
* @see org.elasticsearch.index.query.QueryBuilders
|
||||
*/
|
||||
public DeleteByQueryRequestBuilder setQuery(QueryBuilder queryBuilder) {
|
||||
request.query(queryBuilder);
|
||||
|
|
|
@ -29,8 +29,8 @@ import org.elasticsearch.client.Client;
|
|||
import org.elasticsearch.client.action.support.BaseRequestBuilder;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.xcontent.XContentFilterBuilder;
|
||||
import org.elasticsearch.index.query.xcontent.XContentQueryBuilder;
|
||||
import org.elasticsearch.index.query.FilterBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.search.Scroll;
|
||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
import org.elasticsearch.search.facet.AbstractFacetBuilder;
|
||||
|
@ -190,9 +190,9 @@ public class SearchRequestBuilder extends BaseRequestBuilder<SearchRequest, Sear
|
|||
/**
|
||||
* Constructs a new search source builder with a search query.
|
||||
*
|
||||
* @see org.elasticsearch.index.query.xcontent.QueryBuilders
|
||||
* @see org.elasticsearch.index.query.QueryBuilders
|
||||
*/
|
||||
public SearchRequestBuilder setQuery(XContentQueryBuilder queryBuilder) {
|
||||
public SearchRequestBuilder setQuery(QueryBuilder queryBuilder) {
|
||||
sourceBuilder().query(queryBuilder);
|
||||
return this;
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ public class SearchRequestBuilder extends BaseRequestBuilder<SearchRequest, Sear
|
|||
* Sets a filter on the query executed that only applies to the search query
|
||||
* (and not facets for example).
|
||||
*/
|
||||
public SearchRequestBuilder setFilter(XContentFilterBuilder filter) {
|
||||
public SearchRequestBuilder setFilter(FilterBuilder filter) {
|
||||
sourceBuilder().filter(filter);
|
||||
return this;
|
||||
}
|
||||
|
@ -264,14 +264,6 @@ public class SearchRequestBuilder extends BaseRequestBuilder<SearchRequest, Sear
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* An optional query parser name to use.
|
||||
*/
|
||||
public SearchRequestBuilder setQueryParserName(String queryParserName) {
|
||||
sourceBuilder().queryParserName(queryParserName);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should each {@link org.elasticsearch.search.SearchHit} be returned with an
|
||||
* explanation of the hit (ranking).
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.xcontent.XContentIndexQueryParser;
|
||||
import org.elasticsearch.index.query.IndexQueryParserService;
|
||||
import org.elasticsearch.index.service.IndexService;
|
||||
import org.elasticsearch.indices.IndexMissingException;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
|
@ -101,7 +101,7 @@ public class MetaDataIndexAliasesService extends AbstractComponent {
|
|||
}
|
||||
|
||||
// now, parse the filter
|
||||
XContentIndexQueryParser indexQueryParser = (XContentIndexQueryParser) indexService.queryParserService().defaultIndexQueryParser();
|
||||
IndexQueryParserService indexQueryParser = indexService.queryParserService();
|
||||
try {
|
||||
XContentParser parser = XContentFactory.xContent(filter).createParser(filter);
|
||||
try {
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.IndexQueryParserService;
|
||||
import org.elasticsearch.index.query.xcontent.XContentIndexQueryParser;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
import org.elasticsearch.indices.AliasFilterParsingException;
|
||||
import org.elasticsearch.indices.InvalidAliasNameException;
|
||||
|
@ -48,15 +47,15 @@ import static org.elasticsearch.common.collect.MapBuilder.*;
|
|||
*/
|
||||
public class IndexAliasesService extends AbstractIndexComponent implements Iterable<IndexAlias> {
|
||||
|
||||
private final IndexQueryParserService indexQueryParserService;
|
||||
private final IndexQueryParserService indexQueryParser;
|
||||
|
||||
private volatile ImmutableMap<String, IndexAlias> aliases = ImmutableMap.of();
|
||||
|
||||
private final Object mutex = new Object();
|
||||
|
||||
@Inject public IndexAliasesService(Index index, @IndexSettings Settings indexSettings, IndexQueryParserService indexQueryParserService) {
|
||||
@Inject public IndexAliasesService(Index index, @IndexSettings Settings indexSettings, IndexQueryParserService indexQueryParser) {
|
||||
super(index, indexSettings);
|
||||
this.indexQueryParserService = indexQueryParserService;
|
||||
this.indexQueryParser = indexQueryParser;
|
||||
}
|
||||
|
||||
public boolean hasAlias(String alias) {
|
||||
|
@ -130,7 +129,6 @@ public class IndexAliasesService extends AbstractIndexComponent implements Itera
|
|||
if (filter == null) {
|
||||
return null;
|
||||
}
|
||||
XContentIndexQueryParser indexQueryParser = (XContentIndexQueryParser) indexQueryParserService.defaultIndexQueryParser();
|
||||
try {
|
||||
byte[] filterSource = filter.uncompressed();
|
||||
XContentParser parser = XContentFactory.xContent(filterSource).createParser(filterSource);
|
||||
|
|
|
@ -552,25 +552,19 @@ public interface Engine extends IndexShardComponent, CloseableComponent {
|
|||
|
||||
static class DeleteByQuery {
|
||||
private final Query query;
|
||||
private final String queryParserName;
|
||||
private final byte[] source;
|
||||
private final String[] filteringAliases;
|
||||
private final Filter aliasFilter;
|
||||
private final String[] types;
|
||||
|
||||
public DeleteByQuery(Query query, byte[] source, @Nullable String queryParserName, @Nullable String[] filteringAliases, @Nullable Filter aliasFilter, String... types) {
|
||||
public DeleteByQuery(Query query, byte[] source, @Nullable String[] filteringAliases, @Nullable Filter aliasFilter, String... types) {
|
||||
this.query = query;
|
||||
this.source = source;
|
||||
this.queryParserName = queryParserName;
|
||||
this.types = types;
|
||||
this.filteringAliases = filteringAliases;
|
||||
this.aliasFilter = aliasFilter;
|
||||
}
|
||||
|
||||
public String queryParserName() {
|
||||
return this.queryParserName;
|
||||
}
|
||||
|
||||
public Query query() {
|
||||
return this.query;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.lucene.search.Query;
|
|||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.query.xcontent.QueryParseContext;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
|
@ -141,7 +141,7 @@ public interface FieldMapper<T> {
|
|||
String indexedValue(String value);
|
||||
|
||||
/**
|
||||
* Should the field query {@link #fieldQuery(String, org.elasticsearch.index.query.xcontent.QueryParseContext)} be used when detecting this
|
||||
* Should the field query {@link #fieldQuery(String, org.elasticsearch.index.query.QueryParseContext)} be used when detecting this
|
||||
* field in query string.
|
||||
*/
|
||||
boolean useFieldQueryWithQueryString();
|
||||
|
|
|
@ -23,7 +23,12 @@ import org.apache.lucene.analysis.Analyzer;
|
|||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.FuzzyQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.TermRangeFilter;
|
||||
import org.apache.lucene.search.TermRangeQuery;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.lucene.search.TermFilter;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -33,7 +38,7 @@ import org.elasticsearch.index.mapper.FieldMapper;
|
|||
import org.elasticsearch.index.mapper.FieldMapperListener;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
import org.elasticsearch.index.query.xcontent.QueryParseContext;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.elasticsearch.common.lucene.all.AllTermQuery;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
import org.elasticsearch.index.query.xcontent.QueryParseContext;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.elasticsearch.index.analysis.NamedAnalyzer;
|
|||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
import org.elasticsearch.index.query.xcontent.QueryParseContext;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
import org.elasticsearch.index.mapper.Uid;
|
||||
import org.elasticsearch.index.mapper.UidFieldMapper;
|
||||
import org.elasticsearch.index.query.xcontent.QueryParseContext;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
|
@ -54,10 +54,9 @@ import org.elasticsearch.index.mapper.MapperService;
|
|||
import org.elasticsearch.index.mapper.ParsedDocument;
|
||||
import org.elasticsearch.index.mapper.Uid;
|
||||
import org.elasticsearch.index.mapper.UidFieldMapper;
|
||||
import org.elasticsearch.index.query.IndexQueryParser;
|
||||
import org.elasticsearch.index.query.IndexQueryParserService;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.index.query.xcontent.QueryBuilders;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.service.IndexService;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
import org.elasticsearch.index.shard.service.IndexShard;
|
||||
|
@ -226,8 +225,7 @@ public class PercolatorExecutor extends AbstractIndexComponent {
|
|||
currentFieldName = parser.currentName();
|
||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||
if ("query".equals(currentFieldName)) {
|
||||
IndexQueryParser queryParser = queryParserService.defaultIndexQueryParser();
|
||||
query = queryParser.parse(parser).query();
|
||||
query = queryParserService.parse(parser).query();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -274,8 +272,7 @@ public class PercolatorExecutor extends AbstractIndexComponent {
|
|||
}
|
||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||
if ("query".equals(currentFieldName)) {
|
||||
IndexQueryParser queryParser = queryParserService.defaultIndexQueryParser();
|
||||
query = queryParser.parse(parser).query();
|
||||
query = queryParserService.parse(parser).query();
|
||||
}
|
||||
} else if (token == null) {
|
||||
break;
|
||||
|
@ -299,8 +296,7 @@ public class PercolatorExecutor extends AbstractIndexComponent {
|
|||
public Response percolate(DocAndSourceQueryRequest request) throws ElasticSearchException {
|
||||
Query query = null;
|
||||
if (Strings.hasLength(request.query()) && !request.query().equals("*")) {
|
||||
IndexQueryParser queryParser = queryParserService.defaultIndexQueryParser();
|
||||
query = queryParser.parse(QueryBuilders.queryString(request.query())).query();
|
||||
query = queryParserService.parse(QueryBuilders.queryString(request.query())).query();
|
||||
}
|
||||
return percolate(new DocAndQueryRequest(request.doc(), query));
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.collect.Lists;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -32,14 +32,14 @@ import java.util.ArrayList;
|
|||
*/
|
||||
public class AndFilterBuilder extends BaseFilterBuilder {
|
||||
|
||||
private ArrayList<XContentFilterBuilder> filters = Lists.newArrayList();
|
||||
private ArrayList<FilterBuilder> filters = Lists.newArrayList();
|
||||
|
||||
private Boolean cache;
|
||||
|
||||
private String filterName;
|
||||
|
||||
public AndFilterBuilder(XContentFilterBuilder... filters) {
|
||||
for (XContentFilterBuilder filter : filters) {
|
||||
public AndFilterBuilder(FilterBuilder... filters) {
|
||||
for (FilterBuilder filter : filters) {
|
||||
this.filters.add(filter);
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class AndFilterBuilder extends BaseFilterBuilder {
|
|||
/**
|
||||
* Adds a filter to the list of filters to "and".
|
||||
*/
|
||||
public AndFilterBuilder add(XContentFilterBuilder filterBuilder) {
|
||||
public AndFilterBuilder add(FilterBuilder filterBuilder) {
|
||||
filters.add(filterBuilder);
|
||||
return this;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class AndFilterBuilder extends BaseFilterBuilder {
|
|||
@Override protected void doXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject(AndFilterParser.NAME);
|
||||
builder.startArray("filters");
|
||||
for (XContentFilterBuilder filter : filters) {
|
||||
for (FilterBuilder filter : filters) {
|
||||
filter.toXContent(builder, params);
|
||||
}
|
||||
builder.endArray();
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -26,7 +26,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -37,7 +36,7 @@ import static org.elasticsearch.common.collect.Lists.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class AndFilterParser extends AbstractIndexComponent implements XContentFilterParser {
|
||||
public class AndFilterParser extends AbstractIndexComponent implements FilterParser {
|
||||
|
||||
public static final String NAME = "and";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
|
@ -26,7 +26,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public abstract class BaseFilterBuilder implements XContentFilterBuilder {
|
||||
public abstract class BaseFilterBuilder implements FilterBuilder {
|
||||
|
||||
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject();
|
|
@ -17,20 +17,19 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.io.BytesStream;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.query.QueryBuilderException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public abstract class BaseQueryBuilder implements XContentQueryBuilder {
|
||||
public abstract class BaseQueryBuilder implements QueryBuilder {
|
||||
|
||||
@Override public BytesStream buildAsUnsafeBytes() throws QueryBuilderException {
|
||||
return buildAsUnsafeBytes(XContentType.JSON);
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -41,7 +41,7 @@ public class BoolFilterBuilder extends BaseFilterBuilder {
|
|||
/**
|
||||
* Adds a filter that <b>must</b> appear in the matching documents.
|
||||
*/
|
||||
public BoolFilterBuilder must(XContentFilterBuilder filterBuilder) {
|
||||
public BoolFilterBuilder must(FilterBuilder filterBuilder) {
|
||||
clauses.add(new Clause(filterBuilder, BooleanClause.Occur.MUST));
|
||||
return this;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class BoolFilterBuilder extends BaseFilterBuilder {
|
|||
/**
|
||||
* Adds a filter that <b>must not</b> appear in the matching documents.
|
||||
*/
|
||||
public BoolFilterBuilder mustNot(XContentFilterBuilder filterBuilder) {
|
||||
public BoolFilterBuilder mustNot(FilterBuilder filterBuilder) {
|
||||
clauses.add(new Clause(filterBuilder, BooleanClause.Occur.MUST_NOT));
|
||||
return this;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class BoolFilterBuilder extends BaseFilterBuilder {
|
|||
* with no <tt>MUST</tt> clauses one or more <code>SHOULD</code> clauses must match a document
|
||||
* for the BooleanQuery to match.
|
||||
*/
|
||||
public BoolFilterBuilder should(XContentFilterBuilder filterBuilder) {
|
||||
public BoolFilterBuilder should(FilterBuilder filterBuilder) {
|
||||
clauses.add(new Clause(filterBuilder, BooleanClause.Occur.SHOULD));
|
||||
return this;
|
||||
}
|
||||
|
@ -104,10 +104,10 @@ public class BoolFilterBuilder extends BaseFilterBuilder {
|
|||
}
|
||||
|
||||
private static class Clause {
|
||||
final XContentFilterBuilder filterBuilder;
|
||||
final FilterBuilder filterBuilder;
|
||||
final BooleanClause.Occur occur;
|
||||
|
||||
private Clause(XContentFilterBuilder filterBuilder, BooleanClause.Occur occur) {
|
||||
private Clause(FilterBuilder filterBuilder, BooleanClause.Occur occur) {
|
||||
this.filterBuilder = filterBuilder;
|
||||
this.occur = occur;
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.Filter;
|
||||
|
@ -28,7 +28,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -39,7 +38,7 @@ import static org.elasticsearch.common.collect.Lists.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class BoolFilterParser extends AbstractIndexComponent implements XContentFilterParser {
|
||||
public class BoolFilterParser extends AbstractIndexComponent implements FilterParser {
|
||||
|
||||
public static final String NAME = "bool";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
|
@ -32,11 +32,11 @@ import java.util.List;
|
|||
*/
|
||||
public class BoolQueryBuilder extends BaseQueryBuilder {
|
||||
|
||||
private ArrayList<XContentQueryBuilder> mustClauses = new ArrayList<XContentQueryBuilder>();
|
||||
private ArrayList<QueryBuilder> mustClauses = new ArrayList<QueryBuilder>();
|
||||
|
||||
private ArrayList<XContentQueryBuilder> mustNotClauses = new ArrayList<XContentQueryBuilder>();
|
||||
private ArrayList<QueryBuilder> mustNotClauses = new ArrayList<QueryBuilder>();
|
||||
|
||||
private ArrayList<XContentQueryBuilder> shouldClauses = new ArrayList<XContentQueryBuilder>();
|
||||
private ArrayList<QueryBuilder> shouldClauses = new ArrayList<QueryBuilder>();
|
||||
|
||||
private float boost = -1;
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class BoolQueryBuilder extends BaseQueryBuilder {
|
|||
/**
|
||||
* Adds a query that <b>must</b> appear in the matching documents.
|
||||
*/
|
||||
public BoolQueryBuilder must(XContentQueryBuilder queryBuilder) {
|
||||
public BoolQueryBuilder must(QueryBuilder queryBuilder) {
|
||||
mustClauses.add(queryBuilder);
|
||||
return this;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class BoolQueryBuilder extends BaseQueryBuilder {
|
|||
/**
|
||||
* Adds a query that <b>must not</b> appear in the matching documents.
|
||||
*/
|
||||
public BoolQueryBuilder mustNot(XContentQueryBuilder queryBuilder) {
|
||||
public BoolQueryBuilder mustNot(QueryBuilder queryBuilder) {
|
||||
mustNotClauses.add(queryBuilder);
|
||||
return this;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class BoolQueryBuilder extends BaseQueryBuilder {
|
|||
*
|
||||
* @see #minimumNumberShouldMatch(int)
|
||||
*/
|
||||
public BoolQueryBuilder should(XContentQueryBuilder queryBuilder) {
|
||||
public BoolQueryBuilder should(QueryBuilder queryBuilder) {
|
||||
shouldClauses.add(queryBuilder);
|
||||
return this;
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class BoolQueryBuilder extends BaseQueryBuilder {
|
|||
builder.endObject();
|
||||
}
|
||||
|
||||
private void doXArrayContent(String field, List<XContentQueryBuilder> clauses, XContentBuilder builder, Params params) throws IOException {
|
||||
private void doXArrayContent(String field, List<QueryBuilder> clauses, XContentBuilder builder, Params params) throws IOException {
|
||||
if (clauses.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ public class BoolQueryBuilder extends BaseQueryBuilder {
|
|||
clauses.get(0).toXContent(builder, params);
|
||||
} else {
|
||||
builder.startArray(field);
|
||||
for (XContentQueryBuilder clause : clauses) {
|
||||
for (QueryBuilder clause : clauses) {
|
||||
clause.toXContent(builder, params);
|
||||
}
|
||||
builder.endArray();
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
|
@ -27,7 +27,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -39,7 +38,7 @@ import static org.elasticsearch.common.lucene.search.Queries.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class BoolQueryParser extends AbstractIndexComponent implements XContentQueryParser {
|
||||
public class BoolQueryParser extends AbstractIndexComponent implements QueryParser {
|
||||
|
||||
public static final String NAME = "bool";
|
||||
|
|
@ -17,10 +17,9 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilderException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -38,9 +37,9 @@ import java.io.IOException;
|
|||
*/
|
||||
public class BoostingQueryBuilder extends BaseQueryBuilder {
|
||||
|
||||
private XContentQueryBuilder positiveQuery;
|
||||
private QueryBuilder positiveQuery;
|
||||
|
||||
private XContentQueryBuilder negativeQuery;
|
||||
private QueryBuilder negativeQuery;
|
||||
|
||||
private float negativeBoost = -1;
|
||||
|
||||
|
@ -50,12 +49,12 @@ public class BoostingQueryBuilder extends BaseQueryBuilder {
|
|||
|
||||
}
|
||||
|
||||
public BoostingQueryBuilder positive(XContentQueryBuilder positiveQuery) {
|
||||
public BoostingQueryBuilder positive(QueryBuilder positiveQuery) {
|
||||
this.positiveQuery = positiveQuery;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BoostingQueryBuilder negative(XContentQueryBuilder negativeQuery) {
|
||||
public BoostingQueryBuilder negative(QueryBuilder negativeQuery) {
|
||||
this.negativeQuery = negativeQuery;
|
||||
return this;
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.BoostingQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
|
@ -26,7 +26,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -34,7 +33,7 @@ import java.io.IOException;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class BoostingQueryParser extends AbstractIndexComponent implements XContentQueryParser {
|
||||
public class BoostingQueryParser extends AbstractIndexComponent implements QueryParser {
|
||||
|
||||
public static final String NAME = "boosting";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
|
@ -31,7 +31,7 @@ import java.io.IOException;
|
|||
*/
|
||||
public class ConstantScoreQueryBuilder extends BaseQueryBuilder {
|
||||
|
||||
private final XContentFilterBuilder filterBuilder;
|
||||
private final FilterBuilder filterBuilder;
|
||||
|
||||
private float boost = -1;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class ConstantScoreQueryBuilder extends BaseQueryBuilder {
|
|||
*
|
||||
* @param filterBuilder The filter to wrap in a constant score query
|
||||
*/
|
||||
public ConstantScoreQueryBuilder(XContentFilterBuilder filterBuilder) {
|
||||
public ConstantScoreQueryBuilder(FilterBuilder filterBuilder) {
|
||||
this.filterBuilder = filterBuilder;
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.DeletionAwareConstantScoreQuery;
|
||||
|
@ -29,7 +29,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -37,7 +36,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class ConstantScoreQueryParser extends AbstractIndexComponent implements XContentQueryParser {
|
||||
public class ConstantScoreQueryParser extends AbstractIndexComponent implements QueryParser {
|
||||
|
||||
public static final String NAME = "constant_score";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
|
@ -30,7 +30,7 @@ import java.io.IOException;
|
|||
*/
|
||||
public class CustomBoostFactorQueryBuilder extends BaseQueryBuilder {
|
||||
|
||||
private final XContentQueryBuilder queryBuilder;
|
||||
private final QueryBuilder queryBuilder;
|
||||
|
||||
private float boostFactor = -1;
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class CustomBoostFactorQueryBuilder extends BaseQueryBuilder {
|
|||
*
|
||||
* @param queryBuilder The query to apply the boost factor to.
|
||||
*/
|
||||
public CustomBoostFactorQueryBuilder(XContentQueryBuilder queryBuilder) {
|
||||
public CustomBoostFactorQueryBuilder(QueryBuilder queryBuilder) {
|
||||
this.queryBuilder = queryBuilder;
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -28,7 +28,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -36,7 +35,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class CustomBoostFactorQueryParser extends AbstractIndexComponent implements XContentQueryParser {
|
||||
public class CustomBoostFactorQueryParser extends AbstractIndexComponent implements QueryParser {
|
||||
|
||||
public static final String NAME = "custom_boost_factor";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.collect.Maps;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -32,7 +32,7 @@ import java.util.Map;
|
|||
*/
|
||||
public class CustomScoreQueryBuilder extends BaseQueryBuilder {
|
||||
|
||||
private final XContentQueryBuilder queryBuilder;
|
||||
private final QueryBuilder queryBuilder;
|
||||
|
||||
private String script;
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class CustomScoreQueryBuilder extends BaseQueryBuilder {
|
|||
*
|
||||
* @param queryBuilder The query to apply the boost factor to.
|
||||
*/
|
||||
public CustomScoreQueryBuilder(XContentQueryBuilder queryBuilder) {
|
||||
public CustomScoreQueryBuilder(QueryBuilder queryBuilder) {
|
||||
this.queryBuilder = queryBuilder;
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.search.Explanation;
|
||||
|
@ -31,7 +31,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
import org.elasticsearch.script.SearchScript;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
|
@ -42,7 +41,7 @@ import java.util.Map;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class CustomScoreQueryParser extends AbstractIndexComponent implements XContentQueryParser {
|
||||
public class CustomScoreQueryParser extends AbstractIndexComponent implements QueryParser {
|
||||
|
||||
public static final String NAME = "custom_score";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
|
@ -35,7 +35,7 @@ import static org.elasticsearch.common.collect.Lists.*;
|
|||
*/
|
||||
public class DisMaxQueryBuilder extends BaseQueryBuilder {
|
||||
|
||||
private ArrayList<XContentQueryBuilder> queries = newArrayList();
|
||||
private ArrayList<QueryBuilder> queries = newArrayList();
|
||||
|
||||
private float boost = -1;
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class DisMaxQueryBuilder extends BaseQueryBuilder {
|
|||
/**
|
||||
* Add a sub-query to this disjunction.
|
||||
*/
|
||||
public DisMaxQueryBuilder add(XContentQueryBuilder queryBuilder) {
|
||||
public DisMaxQueryBuilder add(QueryBuilder queryBuilder) {
|
||||
queries.add(queryBuilder);
|
||||
return this;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class DisMaxQueryBuilder extends BaseQueryBuilder {
|
|||
builder.field("boost", boost);
|
||||
}
|
||||
builder.startArray("queries");
|
||||
for (XContentQueryBuilder queryBuilder : queries) {
|
||||
for (QueryBuilder queryBuilder : queries) {
|
||||
queryBuilder.toXContent(builder, params);
|
||||
}
|
||||
builder.endArray();
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.DisjunctionMaxQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
|
@ -27,7 +27,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -38,7 +37,7 @@ import static org.elasticsearch.common.collect.Lists.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class DisMaxQueryParser extends AbstractIndexComponent implements XContentQueryParser {
|
||||
public class DisMaxQueryParser extends AbstractIndexComponent implements QueryParser {
|
||||
|
||||
public static final String NAME = "dis_max";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.TermRangeFilter;
|
||||
|
@ -27,7 +27,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -37,7 +36,7 @@ import static org.elasticsearch.index.query.support.QueryParsers.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class ExistsFilterParser extends AbstractIndexComponent implements XContentFilterParser {
|
||||
public class ExistsFilterParser extends AbstractIndexComponent implements FilterParser {
|
||||
|
||||
public static final String NAME = "exists";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.Query;
|
||||
|
@ -27,7 +27,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -38,7 +37,7 @@ import java.io.IOException;
|
|||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class FQueryFilterParser extends AbstractIndexComponent implements XContentFilterParser {
|
||||
public class FQueryFilterParser extends AbstractIndexComponent implements FilterParser {
|
||||
|
||||
public static final String NAME = "fquery";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
|
@ -26,15 +26,15 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*/
|
||||
public class FieldMaskingSpanQueryBuilder extends BaseQueryBuilder implements XContentSpanQueryBuilder {
|
||||
public class FieldMaskingSpanQueryBuilder extends BaseQueryBuilder implements SpanQueryBuilder {
|
||||
|
||||
private final XContentSpanQueryBuilder queryBuilder;
|
||||
private final SpanQueryBuilder queryBuilder;
|
||||
|
||||
private final String field;
|
||||
|
||||
private float boost = -1;
|
||||
|
||||
public FieldMaskingSpanQueryBuilder(XContentSpanQueryBuilder queryBuilder, String field) {
|
||||
public FieldMaskingSpanQueryBuilder(SpanQueryBuilder queryBuilder, String field) {
|
||||
this.queryBuilder = queryBuilder;
|
||||
this.field = field;
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.spans.FieldMaskingSpanQuery;
|
||||
|
@ -29,7 +29,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -37,7 +36,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class FieldMaskingSpanQueryParser extends AbstractIndexComponent implements XContentQueryParser {
|
||||
public class FieldMaskingSpanQueryParser extends AbstractIndexComponent implements QueryParser {
|
||||
|
||||
public static final String NAME = "field_masking_span";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
|
@ -17,11 +17,10 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.queryParser.MapperQueryParser;
|
||||
import org.apache.lucene.queryParser.ParseException;
|
||||
import org.apache.lucene.queryParser.QueryParser;
|
||||
import org.apache.lucene.queryParser.QueryParserSettings;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -31,7 +30,6 @@ import org.elasticsearch.index.AbstractIndexComponent;
|
|||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.cache.query.parser.QueryParserCache;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -41,7 +39,7 @@ import static org.elasticsearch.common.lucene.search.Queries.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class FieldQueryParser extends AbstractIndexComponent implements XContentQueryParser {
|
||||
public class FieldQueryParser extends AbstractIndexComponent implements QueryParser {
|
||||
|
||||
public static final String NAME = "field";
|
||||
|
||||
|
@ -94,9 +92,9 @@ public class FieldQueryParser extends AbstractIndexComponent implements XContent
|
|||
} else if ("default_operator".equals(currentFieldName) || "defaultOperator".equals(currentFieldName)) {
|
||||
String op = parser.text();
|
||||
if ("or".equalsIgnoreCase(op)) {
|
||||
qpSettings.defaultOperator(QueryParser.Operator.OR);
|
||||
qpSettings.defaultOperator(org.apache.lucene.queryParser.QueryParser.Operator.OR);
|
||||
} else if ("and".equalsIgnoreCase(op)) {
|
||||
qpSettings.defaultOperator(QueryParser.Operator.AND);
|
||||
qpSettings.defaultOperator(org.apache.lucene.queryParser.QueryParser.Operator.AND);
|
||||
} else {
|
||||
throw new QueryParsingException(index, "Query default operator [" + op + "] is not allowed");
|
||||
}
|
||||
|
@ -127,7 +125,7 @@ public class FieldQueryParser extends AbstractIndexComponent implements XContent
|
|||
}
|
||||
|
||||
if (qpSettings.escape()) {
|
||||
qpSettings.queryString(QueryParser.escape(qpSettings.queryString()));
|
||||
qpSettings.queryString(org.apache.lucene.queryParser.QueryParser.escape(qpSettings.queryString()));
|
||||
}
|
||||
|
||||
Query query = queryParserCache.get(qpSettings);
|
|
@ -17,13 +17,13 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public interface XContentFilterBuilder extends ToXContent {
|
||||
public interface FilterBuilder extends ToXContent {
|
||||
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.Nullable;
|
||||
|
||||
|
@ -273,7 +273,7 @@ public abstract class FilterBuilders {
|
|||
*
|
||||
* @param queryBuilder The query to wrap as a filter
|
||||
*/
|
||||
public static QueryFilterBuilder queryFilter(XContentQueryBuilder queryBuilder) {
|
||||
public static QueryFilterBuilder queryFilter(QueryBuilder queryBuilder) {
|
||||
return new QueryFilterBuilder(queryBuilder);
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,7 @@ public abstract class FilterBuilders {
|
|||
* @param type The child type
|
||||
* @param query The query to run against the child type
|
||||
*/
|
||||
public static HasChildFilterBuilder hasChildFilter(String type, XContentQueryBuilder query) {
|
||||
public static HasChildFilterBuilder hasChildFilter(String type, QueryBuilder query) {
|
||||
return new HasChildFilterBuilder(type, query);
|
||||
}
|
||||
|
||||
|
@ -355,15 +355,15 @@ public abstract class FilterBuilders {
|
|||
return new BoolFilterBuilder();
|
||||
}
|
||||
|
||||
public static AndFilterBuilder andFilter(XContentFilterBuilder... filters) {
|
||||
public static AndFilterBuilder andFilter(FilterBuilder... filters) {
|
||||
return new AndFilterBuilder(filters);
|
||||
}
|
||||
|
||||
public static OrFilterBuilder orFilter(XContentFilterBuilder... filters) {
|
||||
public static OrFilterBuilder orFilter(FilterBuilder... filters) {
|
||||
return new OrFilterBuilder(filters);
|
||||
}
|
||||
|
||||
public static NotFilterBuilder notFilter(XContentFilterBuilder filter) {
|
||||
public static NotFilterBuilder notFilter(FilterBuilder filter) {
|
||||
return new NotFilterBuilder(filter);
|
||||
}
|
||||
|
|
@ -17,18 +17,17 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.elasticsearch.index.IndexComponent;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public interface XContentFilterParser extends IndexComponent {
|
||||
public interface FilterParser extends IndexComponent {
|
||||
|
||||
/**
|
||||
* The names this filter is registered under.
|
|
@ -17,14 +17,14 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public interface XContentFilterParserFactory {
|
||||
public interface FilterParserFactory {
|
||||
|
||||
XContentFilterParser create(String name, Settings settings);
|
||||
FilterParser create(String name, Settings settings);
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
|
@ -30,9 +30,9 @@ import java.io.IOException;
|
|||
*/
|
||||
public class FilteredQueryBuilder extends BaseQueryBuilder {
|
||||
|
||||
private final XContentQueryBuilder queryBuilder;
|
||||
private final QueryBuilder queryBuilder;
|
||||
|
||||
private final XContentFilterBuilder filterBuilder;
|
||||
private final FilterBuilder filterBuilder;
|
||||
|
||||
private float boost = -1;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class FilteredQueryBuilder extends BaseQueryBuilder {
|
|||
* @param queryBuilder The query to apply the filter to
|
||||
* @param filterBuilder The filter to apply on the query
|
||||
*/
|
||||
public FilteredQueryBuilder(XContentQueryBuilder queryBuilder, XContentFilterBuilder filterBuilder) {
|
||||
public FilteredQueryBuilder(QueryBuilder queryBuilder, FilterBuilder filterBuilder) {
|
||||
this.queryBuilder = queryBuilder;
|
||||
this.filterBuilder = filterBuilder;
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.DeletionAwareConstantScoreQuery;
|
||||
import org.apache.lucene.search.Filter;
|
||||
|
@ -29,7 +29,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -37,7 +36,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class FilteredQueryParser extends AbstractIndexComponent implements XContentQueryParser {
|
||||
public class FilteredQueryParser extends AbstractIndexComponent implements QueryParser {
|
||||
|
||||
public static final String NAME = "filtered";
|
||||
|
|
@ -17,10 +17,9 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilderException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.search.FuzzyLikeThisQuery;
|
||||
|
@ -29,7 +29,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -50,7 +49,7 @@ import static org.elasticsearch.index.query.support.QueryParsers.*;
|
|||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class FuzzyLikeThisFieldQueryParser extends AbstractIndexComponent implements XContentQueryParser {
|
||||
public class FuzzyLikeThisFieldQueryParser extends AbstractIndexComponent implements QueryParser {
|
||||
|
||||
public static final String NAME = "flt_field";
|
||||
|
|
@ -17,10 +17,9 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilderException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.FuzzyLikeThisQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
|
@ -28,7 +28,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.mapper.AllFieldMapper;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -48,7 +47,7 @@ import java.util.List;
|
|||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class FuzzyLikeThisQueryParser extends AbstractIndexComponent implements XContentQueryParser {
|
||||
public class FuzzyLikeThisQueryParser extends AbstractIndexComponent implements QueryParser {
|
||||
|
||||
public static final String NAME = "flt";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.FuzzyQuery;
|
||||
|
@ -28,7 +28,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -38,7 +37,7 @@ import static org.elasticsearch.index.query.support.QueryParsers.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class FuzzyQueryParser extends AbstractIndexComponent implements XContentQueryParser {
|
||||
public class FuzzyQueryParser extends AbstractIndexComponent implements QueryParser {
|
||||
|
||||
public static final String NAME = "fuzzy";
|
||||
|
|
@ -17,10 +17,9 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilderException;
|
||||
import org.elasticsearch.index.search.geo.GeoBoundingBoxFilter;
|
||||
|
||||
import java.io.IOException;
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -29,7 +29,6 @@ import org.elasticsearch.index.mapper.FieldMapper;
|
|||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.mapper.xcontent.geo.GeoPointFieldDataType;
|
||||
import org.elasticsearch.index.mapper.xcontent.geo.GeoPointFieldMapper;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.search.geo.GeoBoundingBoxFilter;
|
||||
import org.elasticsearch.index.search.geo.GeoHashUtils;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
@ -41,7 +40,7 @@ import static org.elasticsearch.index.query.support.QueryParsers.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class GeoBoundingBoxFilterParser extends AbstractIndexComponent implements XContentFilterParser {
|
||||
public class GeoBoundingBoxFilterParser extends AbstractIndexComponent implements FilterParser {
|
||||
|
||||
public static final String NAME = "geo_bbox";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.unit.DistanceUnit;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -30,7 +30,6 @@ import org.elasticsearch.index.mapper.FieldMapper;
|
|||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.mapper.xcontent.geo.GeoPointFieldDataType;
|
||||
import org.elasticsearch.index.mapper.xcontent.geo.GeoPointFieldMapper;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.search.geo.GeoDistance;
|
||||
import org.elasticsearch.index.search.geo.GeoDistanceFilter;
|
||||
import org.elasticsearch.index.search.geo.GeoHashUtils;
|
||||
|
@ -50,7 +49,7 @@ import static org.elasticsearch.index.query.support.QueryParsers.*;
|
|||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class GeoDistanceFilterParser extends AbstractIndexComponent implements XContentFilterParser {
|
||||
public class GeoDistanceFilterParser extends AbstractIndexComponent implements FilterParser {
|
||||
|
||||
public static final String NAME = "geo_distance";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.search.geo.GeoDistance;
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -30,7 +30,6 @@ import org.elasticsearch.index.mapper.FieldMapper;
|
|||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.mapper.xcontent.geo.GeoPointFieldDataType;
|
||||
import org.elasticsearch.index.mapper.xcontent.geo.GeoPointFieldMapper;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.search.geo.GeoDistance;
|
||||
import org.elasticsearch.index.search.geo.GeoDistanceRangeFilter;
|
||||
import org.elasticsearch.index.search.geo.GeoHashUtils;
|
||||
|
@ -50,7 +49,7 @@ import static org.elasticsearch.index.query.support.QueryParsers.*;
|
|||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class GeoDistanceRangeFilterParser extends AbstractIndexComponent implements XContentFilterParser {
|
||||
public class GeoDistanceRangeFilterParser extends AbstractIndexComponent implements FilterParser {
|
||||
|
||||
public static final String NAME = "geo_distance_range";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.collect.Lists;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.elasticsearch.common.collect.Lists;
|
||||
|
@ -30,7 +30,6 @@ import org.elasticsearch.index.mapper.FieldMapper;
|
|||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.mapper.xcontent.geo.GeoPointFieldDataType;
|
||||
import org.elasticsearch.index.mapper.xcontent.geo.GeoPointFieldMapper;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.search.geo.GeoHashUtils;
|
||||
import org.elasticsearch.index.search.geo.GeoPolygonFilter;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
@ -54,7 +53,7 @@ import static org.elasticsearch.index.query.support.QueryParsers.*;
|
|||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class GeoPolygonFilterParser extends AbstractIndexComponent implements XContentFilterParser {
|
||||
public class GeoPolygonFilterParser extends AbstractIndexComponent implements FilterParser {
|
||||
|
||||
public static final String NAME = "geo_polygon";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
|
@ -28,7 +28,7 @@ import java.io.IOException;
|
|||
*/
|
||||
public class HasChildFilterBuilder extends BaseFilterBuilder {
|
||||
|
||||
private final XContentQueryBuilder queryBuilder;
|
||||
private final QueryBuilder queryBuilder;
|
||||
|
||||
private String childType;
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class HasChildFilterBuilder extends BaseFilterBuilder {
|
|||
|
||||
private String filterName;
|
||||
|
||||
public HasChildFilterBuilder(String type, XContentQueryBuilder queryBuilder) {
|
||||
public HasChildFilterBuilder(String type, QueryBuilder queryBuilder) {
|
||||
this.childType = type;
|
||||
this.queryBuilder = queryBuilder;
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.FilteredQuery;
|
||||
|
@ -29,7 +29,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.query.type.child.HasChildFilter;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
|
@ -39,7 +38,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class HasChildFilterParser extends AbstractIndexComponent implements XContentFilterParser {
|
||||
public class HasChildFilterParser extends AbstractIndexComponent implements FilterParser {
|
||||
|
||||
public static final String NAME = "has_child";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
|
@ -28,7 +28,7 @@ import java.io.IOException;
|
|||
*/
|
||||
public class HasChildQueryBuilder extends BaseQueryBuilder {
|
||||
|
||||
private final XContentQueryBuilder queryBuilder;
|
||||
private final QueryBuilder queryBuilder;
|
||||
|
||||
private String childType;
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class HasChildQueryBuilder extends BaseQueryBuilder {
|
|||
|
||||
private float boost = 1.0f;
|
||||
|
||||
public HasChildQueryBuilder(String type, XContentQueryBuilder queryBuilder) {
|
||||
public HasChildQueryBuilder(String type, QueryBuilder queryBuilder) {
|
||||
this.childType = type;
|
||||
this.queryBuilder = queryBuilder;
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.FilteredQuery;
|
||||
|
@ -29,7 +29,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.query.type.child.HasChildFilter;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
|
@ -39,7 +38,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class HasChildQueryParser extends AbstractIndexComponent implements XContentQueryParser {
|
||||
public class HasChildQueryParser extends AbstractIndexComponent implements QueryParser {
|
||||
|
||||
public static final String NAME = "has_child";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.elasticsearch.common.collect.ImmutableList;
|
||||
|
@ -27,7 +27,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.search.UidFilter;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
|
@ -36,7 +35,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class IdsFilterParser extends AbstractIndexComponent implements XContentFilterParser {
|
||||
public class IdsFilterParser extends AbstractIndexComponent implements FilterParser {
|
||||
|
||||
public static final String NAME = "ids";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
|
@ -28,7 +28,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.search.UidFilter;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
|
@ -40,7 +39,7 @@ import java.util.List;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class IdsQueryParser extends AbstractIndexComponent implements XContentQueryParser {
|
||||
public class IdsQueryParser extends AbstractIndexComponent implements QueryParser {
|
||||
|
||||
public static final String NAME = "ids";
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.IndexComponent;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*/
|
||||
public interface IndexQueryParser extends IndexComponent {
|
||||
|
||||
String name();
|
||||
|
||||
void close();
|
||||
|
||||
ParsedQuery parse(byte[] source) throws ElasticSearchException;
|
||||
|
||||
ParsedQuery parse(byte[] source, int offset, int length) throws ElasticSearchException;
|
||||
|
||||
ParsedQuery parse(String source) throws ElasticSearchException;
|
||||
|
||||
ParsedQuery parse(QueryBuilder queryBuilder) throws ElasticSearchException;
|
||||
|
||||
ParsedQuery parse(XContentParser parser) throws ElasticSearchException;
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
/**
|
||||
* Guice Factory for custom {@link IndexQueryParser}.
|
||||
*
|
||||
* @author kimchy (Shay Banon)
|
||||
*/
|
||||
public interface IndexQueryParserFactory {
|
||||
|
||||
IndexQueryParser create(String name, Settings settings);
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*/
|
||||
public class IndexQueryParserMissingException extends ElasticSearchException {
|
||||
|
||||
public IndexQueryParserMissingException(String name) {
|
||||
super("Index Query Parser [" + name + "] missing");
|
||||
}
|
||||
}
|
|
@ -25,7 +25,6 @@ import org.elasticsearch.common.inject.Scopes;
|
|||
import org.elasticsearch.common.inject.assistedinject.FactoryProvider;
|
||||
import org.elasticsearch.common.inject.multibindings.MapBinder;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.query.xcontent.*;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
|
@ -37,43 +36,12 @@ public class IndexQueryParserModule extends AbstractModule {
|
|||
|
||||
/**
|
||||
* A custom processor that can be extended to process and bind custom implementations of
|
||||
* {@link IndexQueryParserFactory}, {@link XContentQueryParserFactory}, and {@link XContentFilterParser}.
|
||||
* {@link QueryParserFactory}, and {@link FilterParser}.
|
||||
*/
|
||||
public static class QueryParsersProcessor {
|
||||
|
||||
/**
|
||||
* Extension point to bind a custom {@link IndexQueryParserFactory}.
|
||||
*/
|
||||
public void processIndexQueryParsers(IndexQueryParsersBindings bindings) {
|
||||
|
||||
}
|
||||
|
||||
public static class IndexQueryParsersBindings {
|
||||
private final MapBinder<String, IndexQueryParserFactory> binder;
|
||||
private final Map<String, Settings> groupSettings;
|
||||
|
||||
public IndexQueryParsersBindings(MapBinder<String, IndexQueryParserFactory> binder, Map<String, Settings> groupSettings) {
|
||||
this.binder = binder;
|
||||
this.groupSettings = groupSettings;
|
||||
}
|
||||
|
||||
public MapBinder<String, IndexQueryParserFactory> binder() {
|
||||
return binder;
|
||||
}
|
||||
|
||||
public Map<String, Settings> groupSettings() {
|
||||
return groupSettings;
|
||||
}
|
||||
|
||||
public void processIndexQueryParser(String name, Class<? extends IndexQueryParser> indexQueryParser) {
|
||||
if (!groupSettings.containsKey(name)) {
|
||||
binder.addBinding(name).toProvider(FactoryProvider.newFactory(IndexQueryParserFactory.class, indexQueryParser)).in(Scopes.SINGLETON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extension point to bind a custom {@link XContentQueryParserFactory}.
|
||||
* Extension point to bind a custom {@link QueryParserFactory}.
|
||||
*/
|
||||
public void processXContentQueryParsers(XContentQueryParsersBindings bindings) {
|
||||
|
||||
|
@ -81,15 +49,15 @@ public class IndexQueryParserModule extends AbstractModule {
|
|||
|
||||
public static class XContentQueryParsersBindings {
|
||||
|
||||
private final MapBinder<String, XContentQueryParserFactory> binder;
|
||||
private final MapBinder<String, QueryParserFactory> binder;
|
||||
private final Map<String, Settings> groupSettings;
|
||||
|
||||
public XContentQueryParsersBindings(MapBinder<String, XContentQueryParserFactory> binder, Map<String, Settings> groupSettings) {
|
||||
public XContentQueryParsersBindings(MapBinder<String, QueryParserFactory> binder, Map<String, Settings> groupSettings) {
|
||||
this.binder = binder;
|
||||
this.groupSettings = groupSettings;
|
||||
}
|
||||
|
||||
public MapBinder<String, XContentQueryParserFactory> binder() {
|
||||
public MapBinder<String, QueryParserFactory> binder() {
|
||||
return binder;
|
||||
}
|
||||
|
||||
|
@ -97,15 +65,15 @@ public class IndexQueryParserModule extends AbstractModule {
|
|||
return groupSettings;
|
||||
}
|
||||
|
||||
public void processXContentQueryParser(String name, Class<? extends XContentQueryParser> xcontentQueryParser) {
|
||||
public void processXContentQueryParser(String name, Class<? extends QueryParser> xcontentQueryParser) {
|
||||
if (!groupSettings.containsKey(name)) {
|
||||
binder.addBinding(name).toProvider(FactoryProvider.newFactory(XContentQueryParserFactory.class, xcontentQueryParser)).in(Scopes.SINGLETON);
|
||||
binder.addBinding(name).toProvider(FactoryProvider.newFactory(QueryParserFactory.class, xcontentQueryParser)).in(Scopes.SINGLETON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extension point to bind a custom {@link XContentFilterParserFactory}.
|
||||
* Extension point to bind a custom {@link FilterParserFactory}.
|
||||
*/
|
||||
public void processXContentFilterParsers(XContentFilterParsersBindings bindings) {
|
||||
|
||||
|
@ -113,15 +81,15 @@ public class IndexQueryParserModule extends AbstractModule {
|
|||
|
||||
public static class XContentFilterParsersBindings {
|
||||
|
||||
private final MapBinder<String, XContentFilterParserFactory> binder;
|
||||
private final MapBinder<String, FilterParserFactory> binder;
|
||||
private final Map<String, Settings> groupSettings;
|
||||
|
||||
public XContentFilterParsersBindings(MapBinder<String, XContentFilterParserFactory> binder, Map<String, Settings> groupSettings) {
|
||||
public XContentFilterParsersBindings(MapBinder<String, FilterParserFactory> binder, Map<String, Settings> groupSettings) {
|
||||
this.binder = binder;
|
||||
this.groupSettings = groupSettings;
|
||||
}
|
||||
|
||||
public MapBinder<String, XContentFilterParserFactory> binder() {
|
||||
public MapBinder<String, FilterParserFactory> binder() {
|
||||
return binder;
|
||||
}
|
||||
|
||||
|
@ -129,9 +97,9 @@ public class IndexQueryParserModule extends AbstractModule {
|
|||
return groupSettings;
|
||||
}
|
||||
|
||||
public void processXContentQueryFilter(String name, Class<? extends XContentFilterParser> xcontentFilterParser) {
|
||||
public void processXContentQueryFilter(String name, Class<? extends FilterParser> xcontentFilterParser) {
|
||||
if (!groupSettings.containsKey(name)) {
|
||||
binder.addBinding(name).toProvider(FactoryProvider.newFactory(XContentFilterParserFactory.class, xcontentFilterParser)).in(Scopes.SINGLETON);
|
||||
binder.addBinding(name).toProvider(FactoryProvider.newFactory(FilterParserFactory.class, xcontentFilterParser)).in(Scopes.SINGLETON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -154,39 +122,20 @@ public class IndexQueryParserModule extends AbstractModule {
|
|||
|
||||
@Override protected void configure() {
|
||||
|
||||
// handle IndexQueryParsers
|
||||
MapBinder<String, IndexQueryParserFactory> qbinder
|
||||
= MapBinder.newMapBinder(binder(), String.class, IndexQueryParserFactory.class);
|
||||
|
||||
Map<String, Settings> queryParserGroupSettings = settings.getGroups(IndexQueryParserService.Defaults.PREFIX);
|
||||
for (Map.Entry<String, Settings> entry : queryParserGroupSettings.entrySet()) {
|
||||
String qName = entry.getKey();
|
||||
Settings qSettings = entry.getValue();
|
||||
qbinder.addBinding(qName).toProvider(FactoryProvider.newFactory(IndexQueryParserFactory.class,
|
||||
qSettings.getAsClass("type", XContentIndexQueryParser.class))).in(Scopes.SINGLETON);
|
||||
}
|
||||
if (!queryParserGroupSettings.containsKey(IndexQueryParserService.Defaults.DEFAULT)) {
|
||||
qbinder.addBinding(IndexQueryParserService.Defaults.DEFAULT).toProvider(FactoryProvider.newFactory(IndexQueryParserFactory.class,
|
||||
XContentIndexQueryParser.class)).in(Scopes.SINGLETON);
|
||||
}
|
||||
|
||||
QueryParsersProcessor.IndexQueryParsersBindings queryParsersBindings = new QueryParsersProcessor.IndexQueryParsersBindings(qbinder, queryParserGroupSettings);
|
||||
for (QueryParsersProcessor processor : processors) {
|
||||
processor.processIndexQueryParsers(queryParsersBindings);
|
||||
}
|
||||
bind(IndexQueryParserService.class).asEagerSingleton();
|
||||
|
||||
// handle XContenQueryParsers
|
||||
MapBinder<String, XContentQueryParserFactory> queryBinder
|
||||
= MapBinder.newMapBinder(binder(), String.class, XContentQueryParserFactory.class);
|
||||
Map<String, Settings> xContentQueryParserGroups = settings.getGroups(XContentIndexQueryParser.Defaults.QUERY_PREFIX);
|
||||
MapBinder<String, QueryParserFactory> queryBinder
|
||||
= MapBinder.newMapBinder(binder(), String.class, QueryParserFactory.class);
|
||||
Map<String, Settings> xContentQueryParserGroups = settings.getGroups(IndexQueryParserService.Defaults.QUERY_PREFIX);
|
||||
for (Map.Entry<String, Settings> entry : xContentQueryParserGroups.entrySet()) {
|
||||
String qName = entry.getKey();
|
||||
Settings qSettings = entry.getValue();
|
||||
Class<? extends XContentQueryParser> type = qSettings.getAsClass("type", null);
|
||||
Class<? extends QueryParser> type = qSettings.getAsClass("type", null);
|
||||
if (type == null) {
|
||||
throw new IllegalArgumentException("Query Parser [" + qName + "] must be provided with a type");
|
||||
}
|
||||
queryBinder.addBinding(qName).toProvider(FactoryProvider.newFactory(XContentQueryParserFactory.class,
|
||||
queryBinder.addBinding(qName).toProvider(FactoryProvider.newFactory(QueryParserFactory.class,
|
||||
qSettings.getAsClass("type", null))).in(Scopes.SINGLETON);
|
||||
}
|
||||
|
||||
|
@ -196,17 +145,17 @@ public class IndexQueryParserModule extends AbstractModule {
|
|||
}
|
||||
|
||||
// handle XContentFilterParsers
|
||||
MapBinder<String, XContentFilterParserFactory> filterBinder
|
||||
= MapBinder.newMapBinder(binder(), String.class, XContentFilterParserFactory.class);
|
||||
Map<String, Settings> xContentFilterParserGroups = settings.getGroups(XContentIndexQueryParser.Defaults.FILTER_PREFIX);
|
||||
MapBinder<String, FilterParserFactory> filterBinder
|
||||
= MapBinder.newMapBinder(binder(), String.class, FilterParserFactory.class);
|
||||
Map<String, Settings> xContentFilterParserGroups = settings.getGroups(IndexQueryParserService.Defaults.FILTER_PREFIX);
|
||||
for (Map.Entry<String, Settings> entry : xContentFilterParserGroups.entrySet()) {
|
||||
String fName = entry.getKey();
|
||||
Settings fSettings = entry.getValue();
|
||||
Class<? extends XContentFilterParser> type = fSettings.getAsClass("type", null);
|
||||
Class<? extends FilterParser> type = fSettings.getAsClass("type", null);
|
||||
if (type == null) {
|
||||
throw new IllegalArgumentException("Filter Parser [" + fName + "] must be provided with a type");
|
||||
}
|
||||
filterBinder.addBinding(fName).toProvider(FactoryProvider.newFactory(XContentFilterParserFactory.class,
|
||||
filterBinder.addBinding(fName).toProvider(FactoryProvider.newFactory(FilterParserFactory.class,
|
||||
fSettings.getAsClass("type", null))).in(Scopes.SINGLETON);
|
||||
}
|
||||
|
||||
|
@ -214,8 +163,6 @@ public class IndexQueryParserModule extends AbstractModule {
|
|||
for (QueryParsersProcessor processor : processors) {
|
||||
processor.processXContentFilterParsers(xContentFilterParsersBindings);
|
||||
}
|
||||
|
||||
bind(IndexQueryParserService.class).asEagerSingleton();
|
||||
}
|
||||
|
||||
private static class DefaultQueryProcessors extends QueryParsersProcessor {
|
||||
|
|
|
@ -19,16 +19,30 @@
|
|||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.io.BytesStream;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.cache.IndexCache;
|
||||
import org.elasticsearch.index.engine.IndexEngine;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
import org.elasticsearch.index.similarity.SimilarityService;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.common.collect.Lists.*;
|
||||
import static org.elasticsearch.common.collect.Maps.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*;
|
||||
|
||||
|
@ -38,50 +52,188 @@ import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*;
|
|||
public class IndexQueryParserService extends AbstractIndexComponent {
|
||||
|
||||
public static final class Defaults {
|
||||
public static final String DEFAULT = "default";
|
||||
public static final String PREFIX = "index.queryparser.types";
|
||||
public static final String QUERY_PREFIX = "index.queryparser.query";
|
||||
public static final String FILTER_PREFIX = "index.queryparser.filter";
|
||||
}
|
||||
|
||||
private final IndexQueryParser defaultIndexQueryParser;
|
||||
|
||||
private final Map<String, IndexQueryParser> indexQueryParsers;
|
||||
|
||||
@Inject public IndexQueryParserService(Index index, @IndexSettings Settings indexSettings,
|
||||
@Nullable Map<String, IndexQueryParserFactory> indexQueryParsersFactories) {
|
||||
super(index, indexSettings);
|
||||
Map<String, Settings> queryParserGroupSettings;
|
||||
if (indexSettings != null) {
|
||||
queryParserGroupSettings = indexSettings.getGroups(Defaults.PREFIX);
|
||||
} else {
|
||||
queryParserGroupSettings = newHashMap();
|
||||
private ThreadLocal<QueryParseContext> cache = new ThreadLocal<QueryParseContext>() {
|
||||
@Override protected QueryParseContext initialValue() {
|
||||
return new QueryParseContext(index, IndexQueryParserService.this);
|
||||
}
|
||||
Map<String, IndexQueryParser> qparsers = newHashMap();
|
||||
if (indexQueryParsersFactories != null) {
|
||||
for (Map.Entry<String, IndexQueryParserFactory> entry : indexQueryParsersFactories.entrySet()) {
|
||||
String qparserName = entry.getKey();
|
||||
Settings qparserSettings = queryParserGroupSettings.get(qparserName);
|
||||
if (qparserSettings == null) {
|
||||
qparserSettings = EMPTY_SETTINGS;
|
||||
};
|
||||
|
||||
final ScriptService scriptService;
|
||||
|
||||
final MapperService mapperService;
|
||||
|
||||
final SimilarityService similarityService;
|
||||
|
||||
final IndexCache indexCache;
|
||||
|
||||
final IndexEngine indexEngine;
|
||||
|
||||
private final Map<String, QueryParser> queryParsers;
|
||||
|
||||
private final Map<String, FilterParser> filterParsers;
|
||||
|
||||
@Inject public IndexQueryParserService(Index index,
|
||||
@IndexSettings Settings indexSettings, ScriptService scriptService,
|
||||
MapperService mapperService, IndexCache indexCache, IndexEngine indexEngine,
|
||||
@Nullable SimilarityService similarityService,
|
||||
@Nullable Map<String, QueryParserFactory> namedQueryParsers,
|
||||
@Nullable Map<String, FilterParserFactory> namedFilterParsers) {
|
||||
super(index, indexSettings);
|
||||
this.scriptService = scriptService;
|
||||
this.mapperService = mapperService;
|
||||
this.similarityService = similarityService;
|
||||
this.indexCache = indexCache;
|
||||
this.indexEngine = indexEngine;
|
||||
|
||||
List<QueryParser> queryParsers = newArrayList();
|
||||
if (namedQueryParsers != null) {
|
||||
Map<String, Settings> queryParserGroups = indexSettings.getGroups(IndexQueryParserService.Defaults.QUERY_PREFIX);
|
||||
for (Map.Entry<String, QueryParserFactory> entry : namedQueryParsers.entrySet()) {
|
||||
String queryParserName = entry.getKey();
|
||||
QueryParserFactory queryParserFactory = entry.getValue();
|
||||
Settings queryParserSettings = queryParserGroups.get(queryParserName);
|
||||
if (queryParserSettings == null) {
|
||||
queryParserSettings = EMPTY_SETTINGS;
|
||||
}
|
||||
qparsers.put(qparserName, entry.getValue().create(qparserName, qparserSettings));
|
||||
queryParsers.add(queryParserFactory.create(queryParserName, queryParserSettings));
|
||||
}
|
||||
}
|
||||
indexQueryParsers = ImmutableMap.copyOf(qparsers);
|
||||
|
||||
defaultIndexQueryParser = indexQueryParser(Defaults.DEFAULT);
|
||||
Map<String, QueryParser> queryParsersMap = newHashMap();
|
||||
if (queryParsers != null) {
|
||||
for (QueryParser queryParser : queryParsers) {
|
||||
add(queryParsersMap, queryParser);
|
||||
}
|
||||
}
|
||||
this.queryParsers = ImmutableMap.copyOf(queryParsersMap);
|
||||
|
||||
List<FilterParser> filterParsers = newArrayList();
|
||||
if (namedFilterParsers != null) {
|
||||
Map<String, Settings> filterParserGroups = indexSettings.getGroups(IndexQueryParserService.Defaults.FILTER_PREFIX);
|
||||
for (Map.Entry<String, FilterParserFactory> entry : namedFilterParsers.entrySet()) {
|
||||
String filterParserName = entry.getKey();
|
||||
FilterParserFactory filterParserFactory = entry.getValue();
|
||||
Settings filterParserSettings = filterParserGroups.get(filterParserName);
|
||||
if (filterParserSettings == null) {
|
||||
filterParserSettings = EMPTY_SETTINGS;
|
||||
}
|
||||
filterParsers.add(filterParserFactory.create(filterParserName, filterParserSettings));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, FilterParser> filterParsersMap = newHashMap();
|
||||
if (filterParsers != null) {
|
||||
for (FilterParser filterParser : filterParsers) {
|
||||
add(filterParsersMap, filterParser);
|
||||
}
|
||||
}
|
||||
this.filterParsers = ImmutableMap.copyOf(filterParsersMap);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
for (IndexQueryParser indexQueryParser : indexQueryParsers.values()) {
|
||||
indexQueryParser.close();
|
||||
cache.remove();
|
||||
}
|
||||
|
||||
public QueryParser queryParser(String name) {
|
||||
return queryParsers.get(name);
|
||||
}
|
||||
|
||||
public FilterParser filterParser(String name) {
|
||||
return filterParsers.get(name);
|
||||
}
|
||||
|
||||
public ParsedQuery parse(QueryBuilder queryBuilder) throws ElasticSearchException {
|
||||
XContentParser parser = null;
|
||||
try {
|
||||
BytesStream unsafeBytes = queryBuilder.buildAsUnsafeBytes();
|
||||
parser = XContentFactory.xContent(unsafeBytes.unsafeByteArray(), 0, unsafeBytes.size()).createParser(unsafeBytes.unsafeByteArray(), 0, unsafeBytes.size());
|
||||
return parse(cache.get(), parser);
|
||||
} catch (QueryParsingException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new QueryParsingException(index, "Failed to parse", e);
|
||||
} finally {
|
||||
if (parser != null) {
|
||||
parser.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IndexQueryParser indexQueryParser(String name) {
|
||||
return indexQueryParsers.get(name);
|
||||
public ParsedQuery parse(byte[] source) throws ElasticSearchException {
|
||||
return parse(source, 0, source.length);
|
||||
}
|
||||
|
||||
public IndexQueryParser defaultIndexQueryParser() {
|
||||
return defaultIndexQueryParser;
|
||||
public ParsedQuery parse(byte[] source, int offset, int length) throws ElasticSearchException {
|
||||
XContentParser parser = null;
|
||||
try {
|
||||
parser = XContentFactory.xContent(source, offset, length).createParser(source, offset, length);
|
||||
return parse(cache.get(), parser);
|
||||
} catch (QueryParsingException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new QueryParsingException(index, "Failed to parse", e);
|
||||
} finally {
|
||||
if (parser != null) {
|
||||
parser.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ParsedQuery parse(String source) throws QueryParsingException {
|
||||
XContentParser parser = null;
|
||||
try {
|
||||
parser = XContentFactory.xContent(source).createParser(source);
|
||||
return parse(cache.get(), parser);
|
||||
} catch (QueryParsingException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new QueryParsingException(index, "Failed to parse [" + source + "]", e);
|
||||
} finally {
|
||||
if (parser != null) {
|
||||
parser.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ParsedQuery parse(XContentParser parser) {
|
||||
try {
|
||||
return parse(cache.get(), parser);
|
||||
} catch (IOException e) {
|
||||
throw new QueryParsingException(index, "Failed to parse", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Filter parseInnerFilter(XContentParser parser) throws IOException {
|
||||
QueryParseContext context = cache.get();
|
||||
context.reset(parser);
|
||||
return context.parseInnerFilter();
|
||||
}
|
||||
|
||||
public Query parseInnerQuery(XContentParser parser) throws IOException {
|
||||
QueryParseContext context = cache.get();
|
||||
context.reset(parser);
|
||||
return context.parseInnerQuery();
|
||||
}
|
||||
|
||||
private ParsedQuery parse(QueryParseContext parseContext, XContentParser parser) throws IOException, QueryParsingException {
|
||||
parseContext.reset(parser);
|
||||
Query query = parseContext.parseInnerQuery();
|
||||
return new ParsedQuery(query, parseContext.copyNamedFilters());
|
||||
}
|
||||
|
||||
private void add(Map<String, FilterParser> map, FilterParser filterParser) {
|
||||
for (String name : filterParser.names()) {
|
||||
map.put(name.intern(), filterParser);
|
||||
}
|
||||
}
|
||||
|
||||
private void add(Map<String, QueryParser> map, QueryParser queryParser) {
|
||||
for (String name : queryParser.names()) {
|
||||
map.put(name.intern(), queryParser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -26,12 +26,11 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class LimitFilterParser extends AbstractIndexComponent implements XContentFilterParser {
|
||||
public class LimitFilterParser extends AbstractIndexComponent implements FilterParser {
|
||||
|
||||
public static final String NAME = "limit";
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -27,7 +27,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -35,7 +34,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class MatchAllFilterParser extends AbstractIndexComponent implements XContentFilterParser {
|
||||
public class MatchAllFilterParser extends AbstractIndexComponent implements FilterParser {
|
||||
|
||||
public static final String NAME = "match_all";
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue