mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 13:08:29 +00:00
Merge pull request #13418 from jpountz/fix/query_deprecations
Remove support for deprecated queries.
This commit is contained in:
commit
8027b4a1b4
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch 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.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* A filter that matches documents matching boolean combinations of other filters.
|
||||
* @deprecated Use {@link BoolQueryBuilder} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public class AndQueryBuilder extends QueryBuilder {
|
||||
|
||||
private ArrayList<QueryBuilder> filters = new ArrayList<>();
|
||||
|
||||
private String queryName;
|
||||
|
||||
public AndQueryBuilder(QueryBuilder... filters) {
|
||||
for (QueryBuilder filter : filters) {
|
||||
this.filters.add(filter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a filter to the list of filters to "and".
|
||||
*/
|
||||
public AndQueryBuilder add(QueryBuilder filterBuilder) {
|
||||
filters.add(filterBuilder);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the filter name for the filter that can be used when searching for matched_filters per hit.
|
||||
*/
|
||||
public AndQueryBuilder queryName(String queryName) {
|
||||
this.queryName = queryName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject(AndQueryParser.NAME);
|
||||
builder.startArray("filters");
|
||||
for (QueryBuilder filter : filters) {
|
||||
filter.toXContent(builder, params);
|
||||
}
|
||||
builder.endArray();
|
||||
if (queryName != null) {
|
||||
builder.field("_name", queryName);
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch 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.apache.lucene.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class AndQueryParser implements QueryParser {
|
||||
|
||||
public static final String NAME = "and";
|
||||
|
||||
@Inject
|
||||
public AndQueryParser() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] names() {
|
||||
return new String[]{NAME};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
ArrayList<Query> queries = new ArrayList<>();
|
||||
boolean queriesFound = false;
|
||||
|
||||
String queryName = null;
|
||||
String currentFieldName = null;
|
||||
XContentParser.Token token = parser.currentToken();
|
||||
if (token == XContentParser.Token.START_ARRAY) {
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||
queriesFound = true;
|
||||
Query filter = parseContext.parseInnerFilter();
|
||||
if (filter != null) {
|
||||
queries.add(filter);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentFieldName = parser.currentName();
|
||||
} else if (parseContext.isDeprecatedSetting(currentFieldName)) {
|
||||
// skip
|
||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||
if ("filters".equals(currentFieldName)) {
|
||||
queriesFound = true;
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||
Query filter = parseContext.parseInnerFilter();
|
||||
if (filter != null) {
|
||||
queries.add(filter);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
queriesFound = true;
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||
Query filter = parseContext.parseInnerFilter();
|
||||
if (filter != null) {
|
||||
queries.add(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[and] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!queriesFound) {
|
||||
throw new QueryParsingException(parseContext, "[and] query requires 'filters' to be set on it'");
|
||||
}
|
||||
|
||||
if (queries.isEmpty()) {
|
||||
// no filters provided, this should be ignored upstream
|
||||
return null;
|
||||
}
|
||||
|
||||
BooleanQuery.Builder queryBuilder = new BooleanQuery.Builder();
|
||||
for (Query f : queries) {
|
||||
queryBuilder.add(f, Occur.MUST);
|
||||
}
|
||||
BooleanQuery query = queryBuilder.build();
|
||||
if (queryName != null) {
|
||||
parseContext.addNamedQuery(queryName, query);
|
||||
}
|
||||
return query;
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch 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.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* The "fquery" filter is the same as the {@link QueryFilterParser} except that it allows also to
|
||||
* associate a name with the query filter.
|
||||
*/
|
||||
@Deprecated
|
||||
public class FQueryFilterParser implements QueryParser {
|
||||
|
||||
public static final String NAME = "fquery";
|
||||
|
||||
@Inject
|
||||
public FQueryFilterParser() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] names() {
|
||||
return new String[]{NAME};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
Query query = null;
|
||||
boolean queryFound = false;
|
||||
|
||||
String queryName = null;
|
||||
String currentFieldName = null;
|
||||
XContentParser.Token token;
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentFieldName = parser.currentName();
|
||||
} else if (parseContext.isDeprecatedSetting(currentFieldName)) {
|
||||
// skip
|
||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||
if ("query".equals(currentFieldName)) {
|
||||
queryFound = true;
|
||||
query = parseContext.parseInnerQuery();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[fquery] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[fquery] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!queryFound) {
|
||||
throw new QueryParsingException(parseContext, "[fquery] requires 'query' element");
|
||||
}
|
||||
if (query == null) {
|
||||
return null;
|
||||
}
|
||||
query = new ConstantScoreQuery(query);
|
||||
if (queryName != null) {
|
||||
parseContext.addNamedQuery(queryName, query);
|
||||
}
|
||||
return query;
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch 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.Nullable;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A query that applies a filter to the results of another query.
|
||||
* @deprecated Use {@link BoolQueryBuilder} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class FilteredQueryBuilder extends QueryBuilder implements BoostableQueryBuilder<FilteredQueryBuilder> {
|
||||
|
||||
private final QueryBuilder queryBuilder;
|
||||
|
||||
private final QueryBuilder filterBuilder;
|
||||
|
||||
private float boost = -1;
|
||||
|
||||
private String queryName;
|
||||
|
||||
/**
|
||||
* A query that applies a filter to the results of another query.
|
||||
*
|
||||
* @param queryBuilder The query to apply the filter to (Can be null)
|
||||
* @param filterBuilder The filter to apply on the query (Can be null)
|
||||
*/
|
||||
public FilteredQueryBuilder(@Nullable QueryBuilder queryBuilder, @Nullable QueryBuilder filterBuilder) {
|
||||
this.queryBuilder = queryBuilder;
|
||||
this.filterBuilder = filterBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the boost for this query. Documents matching this query will (in addition to the normal
|
||||
* weightings) have their score multiplied by the boost provided.
|
||||
*/
|
||||
@Override
|
||||
public FilteredQueryBuilder boost(float boost) {
|
||||
this.boost = boost;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the query name for the filter that can be used when searching for matched_filters per hit.
|
||||
*/
|
||||
public FilteredQueryBuilder queryName(String queryName) {
|
||||
this.queryName = queryName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject(FilteredQueryParser.NAME);
|
||||
if (queryBuilder != null) {
|
||||
builder.field("query");
|
||||
queryBuilder.toXContent(builder, params);
|
||||
}
|
||||
if (filterBuilder != null) {
|
||||
builder.field("filter");
|
||||
filterBuilder.toXContent(builder, params);
|
||||
}
|
||||
if (boost != -1) {
|
||||
builder.field("boost", boost);
|
||||
}
|
||||
if (queryName != null) {
|
||||
builder.field("_name", queryName);
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch 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.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.lucene.search.Queries;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class FilteredQueryParser implements QueryParser {
|
||||
|
||||
public static final String NAME = "filtered";
|
||||
|
||||
@Inject
|
||||
public FilteredQueryParser() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] names() {
|
||||
return new String[]{NAME};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
Query query = Queries.newMatchAllQuery();
|
||||
Query filter = null;
|
||||
boolean filterFound = false;
|
||||
float boost = 1.0f;
|
||||
String queryName = null;
|
||||
|
||||
String currentFieldName = null;
|
||||
XContentParser.Token token;
|
||||
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentFieldName = parser.currentName();
|
||||
} else if (parseContext.isDeprecatedSetting(currentFieldName)) {
|
||||
// skip
|
||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||
if ("query".equals(currentFieldName)) {
|
||||
query = parseContext.parseInnerQuery();
|
||||
} else if ("filter".equals(currentFieldName)) {
|
||||
filterFound = true;
|
||||
filter = parseContext.parseInnerFilter();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[filtered] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("strategy".equals(currentFieldName)) {
|
||||
// ignore
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else if ("boost".equals(currentFieldName)) {
|
||||
boost = parser.floatValue();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[filtered] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// parsed internally, but returned null during parsing...
|
||||
if (query == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BooleanQuery filteredQuery = Queries.filtered(query, filter);
|
||||
filteredQuery.setBoost(boost);
|
||||
if (queryName != null) {
|
||||
parseContext.addNamedQuery(queryName, filteredQuery);
|
||||
}
|
||||
return filteredQuery;
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch 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.action.search.SearchRequestBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link SearchRequestBuilder#setTerminateAfter(int)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class LimitQueryBuilder extends QueryBuilder {
|
||||
|
||||
private final int limit;
|
||||
|
||||
public LimitQueryBuilder(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject(LimitQueryParser.NAME);
|
||||
builder.field("value", limit);
|
||||
builder.endObject();
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch 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.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.lucene.search.Queries;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Deprecated
|
||||
public class LimitQueryParser implements QueryParser {
|
||||
|
||||
public static final String NAME = "limit";
|
||||
|
||||
@Inject
|
||||
public LimitQueryParser() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] names() {
|
||||
return new String[]{NAME};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
int limit = -1;
|
||||
String currentFieldName = null;
|
||||
XContentParser.Token token;
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentFieldName = parser.currentName();
|
||||
} else if (token.isValue()) {
|
||||
if ("value".equals(currentFieldName)) {
|
||||
limit = parser.intValue();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[limit] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (limit == -1) {
|
||||
throw new QueryParsingException(parseContext, "No value specified for limit query");
|
||||
}
|
||||
|
||||
// this filter is deprecated and parses to a filter that matches everything
|
||||
return Queries.newMatchAllQuery();
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch 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.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* A filter that matches documents matching boolean combinations of other filters.
|
||||
* @deprecated Use {@link BoolQueryBuilder} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public class OrQueryBuilder extends QueryBuilder {
|
||||
|
||||
private ArrayList<QueryBuilder> filters = new ArrayList<>();
|
||||
|
||||
private String queryName;
|
||||
|
||||
public OrQueryBuilder(QueryBuilder... filters) {
|
||||
Collections.addAll(this.filters, filters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a filter to the list of filters to "or".
|
||||
*/
|
||||
public OrQueryBuilder add(QueryBuilder filterBuilder) {
|
||||
filters.add(filterBuilder);
|
||||
return this;
|
||||
}
|
||||
|
||||
public OrQueryBuilder queryName(String queryName) {
|
||||
this.queryName = queryName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject(OrQueryParser.NAME);
|
||||
builder.startArray("filters");
|
||||
for (QueryBuilder filter : filters) {
|
||||
filter.toXContent(builder, params);
|
||||
}
|
||||
builder.endArray();
|
||||
if (queryName != null) {
|
||||
builder.field("_name", queryName);
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch 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.apache.lucene.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class OrQueryParser implements QueryParser {
|
||||
|
||||
public static final String NAME = "or";
|
||||
|
||||
@Inject
|
||||
public OrQueryParser() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] names() {
|
||||
return new String[]{NAME};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
ArrayList<Query> queries = new ArrayList<>();
|
||||
boolean queriesFound = false;
|
||||
|
||||
String queryName = null;
|
||||
String currentFieldName = null;
|
||||
XContentParser.Token token = parser.currentToken();
|
||||
if (token == XContentParser.Token.START_ARRAY) {
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||
queriesFound = true;
|
||||
Query filter = parseContext.parseInnerFilter();
|
||||
if (filter != null) {
|
||||
queries.add(filter);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentFieldName = parser.currentName();
|
||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||
if ("filters".equals(currentFieldName)) {
|
||||
queriesFound = true;
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||
Query filter = parseContext.parseInnerFilter();
|
||||
if (filter != null) {
|
||||
queries.add(filter);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||
queriesFound = true;
|
||||
Query filter = parseContext.parseInnerFilter();
|
||||
if (filter != null) {
|
||||
queries.add(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[or] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!queriesFound) {
|
||||
throw new QueryParsingException(parseContext, "[or] query requires 'filters' to be set on it'");
|
||||
}
|
||||
|
||||
if (queries.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BooleanQuery.Builder queryBuilder = new BooleanQuery.Builder();
|
||||
for (Query f : queries) {
|
||||
queryBuilder.add(f, Occur.SHOULD);
|
||||
}
|
||||
BooleanQuery query = queryBuilder.build();
|
||||
if (queryName != null) {
|
||||
parseContext.addNamedQuery(queryName, query);
|
||||
}
|
||||
return query;
|
||||
}
|
||||
}
|
@ -19,7 +19,6 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
@ -352,19 +351,6 @@ public abstract class QueryBuilders {
|
||||
return new FieldMaskingSpanQueryBuilder(query, field);
|
||||
}
|
||||
|
||||
/**
|
||||
* A query that applies a filter to the results of another query.
|
||||
*
|
||||
* @param queryBuilder The query to apply the filter to
|
||||
* @param filterBuilder The filter to apply on the query
|
||||
* @deprecated Use {@link #boolQuery()} instead with a {@code must} clause
|
||||
* for the query and a {@code filter} clause for the filter.
|
||||
*/
|
||||
@Deprecated
|
||||
public static FilteredQueryBuilder filteredQuery(@Nullable QueryBuilder queryBuilder, @Nullable QueryBuilder filterBuilder) {
|
||||
return new FilteredQueryBuilder(queryBuilder, filterBuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
* A query that wraps another query and simply returns a constant score equal to the
|
||||
* query boost for every document in the query.
|
||||
@ -777,41 +763,6 @@ public abstract class QueryBuilders {
|
||||
return new NotQueryBuilder(filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link OrQueryBuilder} composed of the given filters.
|
||||
* @deprecated Use {@link #boolQuery()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static OrQueryBuilder orQuery(QueryBuilder... filters) {
|
||||
return new OrQueryBuilder(filters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link AndQueryBuilder} composed of the given filters.
|
||||
* @deprecated Use {@link #boolQuery()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static AndQueryBuilder andQuery(QueryBuilder... filters) {
|
||||
return new AndQueryBuilder(filters);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link SearchRequestBuilder#setTerminateAfter(int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static LimitQueryBuilder limitQuery(int limit) {
|
||||
return new LimitQueryBuilder(limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Useless now that queries and filters are merged: pass the
|
||||
* query as a filter directly.
|
||||
*/
|
||||
@Deprecated
|
||||
public static QueryFilterBuilder queryFilter(QueryBuilder query) {
|
||||
return new QueryFilterBuilder(query);
|
||||
}
|
||||
|
||||
private QueryBuilders() {
|
||||
|
||||
}
|
||||
|
@ -28,13 +28,12 @@ import java.io.IOException;
|
||||
* @deprecated Useless now that queries and filters are merged: pass the
|
||||
* query as a filter directly.
|
||||
*/
|
||||
//TODO: remove when https://github.com/elastic/elasticsearch/issues/13326 is fixed
|
||||
@Deprecated
|
||||
public class QueryFilterBuilder extends QueryBuilder {
|
||||
|
||||
private final QueryBuilder queryBuilder;
|
||||
|
||||
private String queryName;
|
||||
|
||||
/**
|
||||
* A filter that simply wraps a query.
|
||||
*
|
||||
@ -44,27 +43,9 @@ public class QueryFilterBuilder extends QueryBuilder {
|
||||
this.queryBuilder = queryBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the query name for the filter that can be used when searching for matched_filters per hit.
|
||||
*/
|
||||
public QueryFilterBuilder queryName(String queryName) {
|
||||
this.queryName = queryName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
if (queryName == null) {
|
||||
builder.field(QueryFilterParser.NAME);
|
||||
queryBuilder.toXContent(builder, params);
|
||||
} else {
|
||||
builder.startObject(FQueryFilterParser.NAME);
|
||||
builder.field("query");
|
||||
queryBuilder.toXContent(builder, params);
|
||||
if (queryName != null) {
|
||||
builder.field("_name", queryName);
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
builder.field(QueryFilterParser.NAME);
|
||||
queryBuilder.toXContent(builder, params);
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,12 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
// TODO: remove when https://github.com/elastic/elasticsearch/issues/13326 is fixed
|
||||
@Deprecated
|
||||
public class QueryFilterParser implements QueryParser {
|
||||
|
||||
@ -41,6 +41,6 @@ public class QueryFilterParser implements QueryParser {
|
||||
|
||||
@Override
|
||||
public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
return new ConstantScoreQuery(parseContext.parseInnerQuery());
|
||||
return parseContext.parseInnerQuery();
|
||||
}
|
||||
}
|
@ -82,7 +82,6 @@ public class IndicesModule extends AbstractModule {
|
||||
registerQueryParser(RangeQueryParser.class);
|
||||
registerQueryParser(PrefixQueryParser.class);
|
||||
registerQueryParser(WildcardQueryParser.class);
|
||||
registerQueryParser(FilteredQueryParser.class);
|
||||
registerQueryParser(ConstantScoreQueryParser.class);
|
||||
registerQueryParser(SpanTermQueryParser.class);
|
||||
registerQueryParser(SpanNotQueryParser.class);
|
||||
@ -101,7 +100,6 @@ public class IndicesModule extends AbstractModule {
|
||||
registerQueryParser(SimpleQueryStringParser.class);
|
||||
registerQueryParser(TemplateQueryParser.class);
|
||||
registerQueryParser(TypeQueryParser.class);
|
||||
registerQueryParser(LimitQueryParser.class);
|
||||
registerQueryParser(ScriptQueryParser.class);
|
||||
registerQueryParser(GeoDistanceQueryParser.class);
|
||||
registerQueryParser(GeoDistanceRangeQueryParser.class);
|
||||
@ -109,9 +107,6 @@ public class IndicesModule extends AbstractModule {
|
||||
registerQueryParser(GeohashCellQuery.Parser.class);
|
||||
registerQueryParser(GeoPolygonQueryParser.class);
|
||||
registerQueryParser(QueryFilterParser.class);
|
||||
registerQueryParser(FQueryFilterParser.class);
|
||||
registerQueryParser(AndQueryParser.class);
|
||||
registerQueryParser(OrQueryParser.class);
|
||||
registerQueryParser(NotQueryParser.class);
|
||||
registerQueryParser(ExistsQueryParser.class);
|
||||
registerQueryParser(MissingQueryParser.class);
|
||||
|
@ -31,9 +31,8 @@ import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.elasticsearch.index.query.QueryBuilders.andQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.notQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
@ -119,11 +118,8 @@ public class HotThreadsIT extends ESIntegTestCase {
|
||||
assertHitCount(
|
||||
client().prepareSearch()
|
||||
.setQuery(matchAllQuery())
|
||||
.setPostFilter(
|
||||
andQuery(
|
||||
matchAllQuery(),
|
||||
notQuery(andQuery(termQuery("field1", "value1"),
|
||||
termQuery("field1", "value2"))))).get(),
|
||||
.setPostFilter(boolQuery().must(matchAllQuery()).mustNot(boolQuery().must(termQuery("field1", "value1")).must(termQuery("field1", "value2"))))
|
||||
.get(),
|
||||
3l);
|
||||
}
|
||||
latch.await();
|
||||
|
@ -36,7 +36,7 @@ import static org.elasticsearch.client.Requests.createIndexRequest;
|
||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
|
||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.filteredQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.hasChildQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
|
||||
@ -167,9 +167,9 @@ public class ChildSearchAndIndexingBenchmark {
|
||||
for (int j = 0; j < QUERY_COUNT; j++) {
|
||||
SearchResponse searchResponse = client.prepareSearch(indexName)
|
||||
.setQuery(
|
||||
filteredQuery(
|
||||
matchAllQuery(),
|
||||
hasChildQuery("child", termQuery("field2", "value" + random.nextInt(numValues)))
|
||||
boolQuery()
|
||||
.must(matchAllQuery())
|
||||
.filter(hasChildQuery("child", termQuery("field2", "value" + random.nextInt(numValues)))
|
||||
)
|
||||
)
|
||||
.execute().actionGet();
|
||||
@ -184,10 +184,9 @@ public class ChildSearchAndIndexingBenchmark {
|
||||
for (int j = 1; j <= QUERY_COUNT; j++) {
|
||||
SearchResponse searchResponse = client.prepareSearch(indexName)
|
||||
.setQuery(
|
||||
filteredQuery(
|
||||
matchAllQuery(),
|
||||
hasChildQuery("child", matchAllQuery())
|
||||
)
|
||||
boolQuery()
|
||||
.must(matchAllQuery())
|
||||
.filter(hasChildQuery("child", matchAllQuery()))
|
||||
)
|
||||
.execute().actionGet();
|
||||
if (searchResponse.getFailedShards() > 0) {
|
||||
|
@ -130,10 +130,9 @@ public class ChildSearchBenchmark {
|
||||
for (int j = 0; j < QUERY_WARMUP; j++) {
|
||||
SearchResponse searchResponse = client.prepareSearch(indexName)
|
||||
.setQuery(
|
||||
filteredQuery(
|
||||
matchAllQuery(),
|
||||
hasChildQuery("child", termQuery("field2", parentChildIndexGenerator.getQueryValue()))
|
||||
)
|
||||
boolQuery()
|
||||
.must(matchAllQuery())
|
||||
.filter(hasChildQuery("child", termQuery("field2", parentChildIndexGenerator.getQueryValue())))
|
||||
)
|
||||
.execute().actionGet();
|
||||
if (searchResponse.getFailedShards() > 0) {
|
||||
@ -145,10 +144,9 @@ public class ChildSearchBenchmark {
|
||||
for (int j = 0; j < QUERY_COUNT; j++) {
|
||||
SearchResponse searchResponse = client.prepareSearch(indexName)
|
||||
.setQuery(
|
||||
filteredQuery(
|
||||
matchAllQuery(),
|
||||
hasChildQuery("child", termQuery("field2", parentChildIndexGenerator.getQueryValue()))
|
||||
)
|
||||
boolQuery()
|
||||
.must(matchAllQuery())
|
||||
.filter(hasChildQuery("child", termQuery("field2", parentChildIndexGenerator.getQueryValue())))
|
||||
)
|
||||
.execute().actionGet();
|
||||
if (searchResponse.getFailedShards() > 0) {
|
||||
@ -166,10 +164,9 @@ public class ChildSearchBenchmark {
|
||||
for (int j = 1; j <= QUERY_COUNT; j++) {
|
||||
SearchResponse searchResponse = client.prepareSearch(indexName)
|
||||
.setQuery(
|
||||
filteredQuery(
|
||||
matchAllQuery(),
|
||||
hasChildQuery("child", matchAllQuery())
|
||||
)
|
||||
boolQuery()
|
||||
.must(matchAllQuery())
|
||||
.filter(hasChildQuery("child", matchAllQuery()))
|
||||
)
|
||||
.execute().actionGet();
|
||||
if (searchResponse.getFailedShards() > 0) {
|
||||
@ -226,10 +223,9 @@ public class ChildSearchBenchmark {
|
||||
for (int j = 0; j < QUERY_WARMUP; j++) {
|
||||
SearchResponse searchResponse = client.prepareSearch(indexName)
|
||||
.setQuery(
|
||||
filteredQuery(
|
||||
matchAllQuery(),
|
||||
hasParentQuery("parent", termQuery("field1", parentChildIndexGenerator.getQueryValue()))
|
||||
)
|
||||
boolQuery()
|
||||
.must(matchAllQuery())
|
||||
.filter(hasParentQuery("parent", termQuery("field1", parentChildIndexGenerator.getQueryValue())))
|
||||
)
|
||||
.execute().actionGet();
|
||||
if (searchResponse.getFailedShards() > 0) {
|
||||
@ -241,10 +237,9 @@ public class ChildSearchBenchmark {
|
||||
for (int j = 1; j <= QUERY_COUNT; j++) {
|
||||
SearchResponse searchResponse = client.prepareSearch(indexName)
|
||||
.setQuery(
|
||||
filteredQuery(
|
||||
matchAllQuery(),
|
||||
hasParentQuery("parent", termQuery("field1", parentChildIndexGenerator.getQueryValue()))
|
||||
)
|
||||
boolQuery()
|
||||
.must(matchAllQuery())
|
||||
.filter(hasParentQuery("parent", termQuery("field1", parentChildIndexGenerator.getQueryValue())))
|
||||
)
|
||||
.execute().actionGet();
|
||||
if (searchResponse.getFailedShards() > 0) {
|
||||
@ -261,10 +256,11 @@ public class ChildSearchBenchmark {
|
||||
totalQueryTime = 0;
|
||||
for (int j = 1; j <= QUERY_COUNT; j++) {
|
||||
SearchResponse searchResponse = client.prepareSearch(indexName)
|
||||
.setQuery(filteredQuery(
|
||||
matchAllQuery(),
|
||||
hasParentQuery("parent", matchAllQuery())
|
||||
))
|
||||
.setQuery(
|
||||
boolQuery()
|
||||
.must(matchAllQuery())
|
||||
.filter(hasParentQuery("parent", matchAllQuery()))
|
||||
)
|
||||
.execute().actionGet();
|
||||
if (searchResponse.getFailedShards() > 0) {
|
||||
System.err.println("Search Failures " + Arrays.toString(searchResponse.getShardFailures()));
|
||||
|
@ -40,7 +40,7 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF
|
||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.filteredQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.hasChildQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
|
||||
@ -158,7 +158,7 @@ public class ChildSearchShortCircuitBenchmark {
|
||||
for (int i = 1; i < PARENT_COUNT; i *= 2) {
|
||||
for (int j = 0; j < QUERY_COUNT; j++) {
|
||||
SearchResponse searchResponse = client.prepareSearch(indexName)
|
||||
.setQuery(filteredQuery(matchAllQuery(), hasChildQuery("child", matchQuery("field2", i))))
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(hasChildQuery("child", matchQuery("field2", i))))
|
||||
.execute().actionGet();
|
||||
if (searchResponse.getHits().totalHits() != i) {
|
||||
System.err.println("--> mismatch on hits");
|
||||
|
@ -31,7 +31,7 @@ import org.elasticsearch.node.NodeBuilder;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.geoDistanceQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.filteredQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
|
||||
/**
|
||||
@ -191,7 +191,7 @@ public class GeoDistanceSearchBenchmark {
|
||||
public static void run(Client client, GeoDistance geoDistance, String optimizeBbox) {
|
||||
client.prepareSearch() // from NY
|
||||
.setSize(0)
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoDistanceQuery("location")
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(geoDistanceQuery("location")
|
||||
.distance("2km")
|
||||
.optimizeBbox(optimizeBbox)
|
||||
.geoDistance(geoDistance)
|
||||
|
@ -414,7 +414,7 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
|
||||
client().prepareIndex(indexName, "type1", "3").setSource(jsonBuilder().startObject().startObject("obj2").field("obj2_val", "1").endObject().field("y1", "y_1").field("field2", "value2_3").endObject()),
|
||||
client().prepareIndex(indexName, "type1", "4").setSource(jsonBuilder().startObject().startObject("obj2").field("obj2_val", "1").endObject().field("y2", "y_2").field("field3", "value3_4").endObject()));
|
||||
|
||||
CountResponse countResponse = client().prepareCount().setQuery(filteredQuery(matchAllQuery(), existsQuery("field1"))).get();
|
||||
CountResponse countResponse = client().prepareCount().setQuery(existsQuery("field1")).get();
|
||||
assertHitCount(countResponse, 2l);
|
||||
|
||||
countResponse = client().prepareCount().setQuery(constantScoreQuery(existsQuery("field1"))).get();
|
||||
@ -423,24 +423,24 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
|
||||
countResponse = client().prepareCount().setQuery(queryStringQuery("_exists_:field1")).get();
|
||||
assertHitCount(countResponse, 2l);
|
||||
|
||||
countResponse = client().prepareCount().setQuery(filteredQuery(matchAllQuery(), existsQuery("field2"))).get();
|
||||
countResponse = client().prepareCount().setQuery(existsQuery("field2")).get();
|
||||
assertHitCount(countResponse, 2l);
|
||||
|
||||
countResponse = client().prepareCount().setQuery(filteredQuery(matchAllQuery(), existsQuery("field3"))).get();
|
||||
countResponse = client().prepareCount().setQuery(existsQuery("field3")).get();
|
||||
assertHitCount(countResponse, 1l);
|
||||
|
||||
// wildcard check
|
||||
countResponse = client().prepareCount().setQuery(filteredQuery(matchAllQuery(), existsQuery("x*"))).get();
|
||||
countResponse = client().prepareCount().setQuery(existsQuery("x*")).get();
|
||||
assertHitCount(countResponse, 2l);
|
||||
|
||||
// object check
|
||||
countResponse = client().prepareCount().setQuery(filteredQuery(matchAllQuery(), existsQuery("obj1"))).get();
|
||||
countResponse = client().prepareCount().setQuery(existsQuery("obj1")).get();
|
||||
assertHitCount(countResponse, 2l);
|
||||
|
||||
countResponse = client().prepareCount().setQuery(filteredQuery(matchAllQuery(), missingQuery("field1"))).get();
|
||||
countResponse = client().prepareCount().setQuery(missingQuery("field1")).get();
|
||||
assertHitCount(countResponse, 2l);
|
||||
|
||||
countResponse = client().prepareCount().setQuery(filteredQuery(matchAllQuery(), missingQuery("field1"))).get();
|
||||
countResponse = client().prepareCount().setQuery(missingQuery("field1")).get();
|
||||
assertHitCount(countResponse, 2l);
|
||||
|
||||
countResponse = client().prepareCount().setQuery(constantScoreQuery(missingQuery("field1"))).get();
|
||||
@ -450,11 +450,11 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
|
||||
assertHitCount(countResponse, 2l);
|
||||
|
||||
// wildcard check
|
||||
countResponse = client().prepareCount().setQuery(filteredQuery(matchAllQuery(), missingQuery("x*"))).get();
|
||||
countResponse = client().prepareCount().setQuery(missingQuery("x*")).get();
|
||||
assertHitCount(countResponse, 2l);
|
||||
|
||||
// object check
|
||||
countResponse = client().prepareCount().setQuery(filteredQuery(matchAllQuery(), missingQuery("obj1"))).get();
|
||||
countResponse = client().prepareCount().setQuery(missingQuery("obj1")).get();
|
||||
assertHitCount(countResponse, 2l);
|
||||
if (!backwardsCluster().upgradeOneNode()) {
|
||||
break;
|
||||
|
@ -27,9 +27,8 @@ import org.apache.lucene.queries.BoostingQuery;
|
||||
import org.apache.lucene.queries.ExtendedCommonTermsQuery;
|
||||
import org.apache.lucene.queries.TermsQuery;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.search.join.ToParentBlockJoinQuery;
|
||||
import org.apache.lucene.search.spans.*;
|
||||
import org.apache.lucene.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.spatial.prefix.IntersectsPrefixTreeFilter;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.BytesRefBuilder;
|
||||
@ -52,8 +51,6 @@ import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.DistanceUnit;
|
||||
import org.elasticsearch.common.unit.Fuzziness;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.engine.Engine;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
@ -533,39 +530,6 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
assertThat((double) prefixQuery.getBoost(), closeTo(1.2, 0.00001));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrefiFilteredQueryBuilder() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
Query parsedQuery = queryParser.parse(filteredQuery(termQuery("name.first", "shay"), prefixQuery("name.first", "sh"))).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new PrefixQuery(new Term("name.first", "sh")));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrefiFilteredQuery() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/prefix-filter.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new PrefixQuery(new Term("name.first", "sh")));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrefixNamedFilteredQuery() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/prefix-filter-named.json");
|
||||
ParsedQuery parsedQuery = queryParser.parse(query);
|
||||
assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true));
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new PrefixQuery(new Term("name.first", "sh")));
|
||||
assertEquals(expected, parsedQuery.query());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrefixQueryBoostQueryBuilder() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
@ -626,62 +590,6 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
assertThat(regexpQuery.getField(), equalTo("name.first"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegexpFilteredQuery() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/regexp-filter.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new RegexpQuery(new Term("name.first", "s.*y")));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegexpFilteredQueryWithMaxDeterminizedStates() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/regexp-filter-max-determinized-states.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new RegexpQuery(new Term("name.first", "s.*y")));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNamedRegexpFilteredQuery() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/regexp-filter-named.json");
|
||||
ParsedQuery parsedQuery = queryParser.parse(query);
|
||||
assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true));
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new RegexpQuery(new Term("name.first", "s.*y")));
|
||||
assertEquals(expected, parsedQuery.query());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegexpWithFlagsFilteredQuery() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/regexp-filter-flags.json");
|
||||
ParsedQuery parsedQuery = queryParser.parse(query);
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new RegexpQuery(new Term("name.first", "s.*y")));
|
||||
assertEquals(expected, parsedQuery.query());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNamedAndCachedRegexpWithFlagsFilteredQuery() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/regexp-filter-flags-named-cached.json");
|
||||
ParsedQuery parsedQuery = queryParser.parse(query);
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new RegexpQuery(new Term("name.first", "s.*y")));
|
||||
assertEquals(expected, parsedQuery.query());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegexpBoostQuery() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
@ -767,176 +675,11 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
assertThat(rangeQuery.includesMax(), equalTo(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRangeFilteredQueryBuilder() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
Query parsedQuery = queryParser.parse(filteredQuery(termQuery("name.first", "shay"), rangeQuery("age").from(23).to(54).includeLower(true).includeUpper(false))).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
NumericRangeQuery.newLongRange("age", 23L, 54L, true, false));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRangeFilteredQuery() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/range-filter.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
NumericRangeQuery.newLongRange("age", 23L, 54L, true, false));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRangeNamedFilteredQuery() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/range-filter-named.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
NumericRangeQuery.newLongRange("age", 23L, 54L, true, false));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoolFilteredQueryBuilder() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
Query parsedQuery = queryParser.parse(filteredQuery(termQuery("name.first", "shay"), boolQuery().must(termQuery("name.first", "shay1")).must(termQuery("name.first", "shay4")).mustNot(termQuery("name.first", "shay2")).should(termQuery("name.first", "shay3")))).query();
|
||||
|
||||
BooleanQuery.Builder filter = new BooleanQuery.Builder();
|
||||
filter.add(new TermQuery(new Term("name.first", "shay1")), Occur.MUST);
|
||||
filter.add(new TermQuery(new Term("name.first", "shay4")), Occur.MUST);
|
||||
filter.add(new TermQuery(new Term("name.first", "shay2")), Occur.MUST_NOT);
|
||||
filter.add(new TermQuery(new Term("name.first", "shay3")), Occur.SHOULD);
|
||||
filter.setMinimumNumberShouldMatch(1);
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
filter.build());
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoolFilteredQuery() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/bool-filter.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
BooleanQuery.Builder filter = new BooleanQuery.Builder();
|
||||
filter.add(new TermQuery(new Term("name.first", "shay1")), Occur.MUST);
|
||||
filter.add(new TermQuery(new Term("name.first", "shay4")), Occur.MUST);
|
||||
filter.add(new TermQuery(new Term("name.first", "shay2")), Occur.MUST_NOT);
|
||||
filter.add(new TermQuery(new Term("name.first", "shay3")), Occur.SHOULD);
|
||||
filter.setMinimumNumberShouldMatch(1);
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
filter.build());
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAndFilteredQueryBuilder() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
Query parsedQuery = queryParser.parse(filteredQuery(matchAllQuery(), andQuery(termQuery("name.first", "shay1"), termQuery("name.first", "shay4")))).query();
|
||||
BooleanQuery.Builder and = new BooleanQuery.Builder();
|
||||
and.add(new TermQuery(new Term("name.first", "shay1")), Occur.MUST);
|
||||
and.add(new TermQuery(new Term("name.first", "shay4")), Occur.MUST);
|
||||
BooleanQuery.Builder builder = new BooleanQuery.Builder();
|
||||
builder.add(new MatchAllDocsQuery(), Occur.MUST);
|
||||
builder.add(and.build(), Occur.FILTER);
|
||||
assertEquals(builder.build(), parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAndFilteredQuery() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/and-filter.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
BooleanQuery.Builder and = new BooleanQuery.Builder();
|
||||
and.add(new TermQuery(new Term("name.first", "shay1")), Occur.MUST);
|
||||
and.add(new TermQuery(new Term("name.first", "shay4")), Occur.MUST);
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
and.build());
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAndNamedFilteredQuery() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/and-filter-named.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
BooleanQuery.Builder and = new BooleanQuery.Builder();
|
||||
and.add(new TermQuery(new Term("name.first", "shay1")), Occur.MUST);
|
||||
and.add(new TermQuery(new Term("name.first", "shay4")), Occur.MUST);
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
and.build());
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAndFilteredQuery2() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/and-filter2.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
BooleanQuery.Builder and = new BooleanQuery.Builder();
|
||||
and.add(new TermQuery(new Term("name.first", "shay1")), Occur.MUST);
|
||||
and.add(new TermQuery(new Term("name.first", "shay4")), Occur.MUST);
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
and.build());
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOrFilteredQueryBuilder() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
Query parsedQuery = queryParser.parse(filteredQuery(matchAllQuery(), orQuery(termQuery("name.first", "shay1"), termQuery("name.first", "shay4")))).query();
|
||||
BooleanQuery.Builder or = new BooleanQuery.Builder();
|
||||
or.add(new TermQuery(new Term("name.first", "shay1")), Occur.SHOULD);
|
||||
or.add(new TermQuery(new Term("name.first", "shay4")), Occur.SHOULD);
|
||||
BooleanQuery.Builder builder = new BooleanQuery.Builder();
|
||||
builder.add(new MatchAllDocsQuery(), Occur.MUST);
|
||||
builder.add(or.build(), Occur.FILTER);
|
||||
assertEquals(builder.build(), parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOrFilteredQuery() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/or-filter.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
BooleanQuery.Builder or = new BooleanQuery.Builder();
|
||||
or.add(new TermQuery(new Term("name.first", "shay1")), Occur.SHOULD);
|
||||
or.add(new TermQuery(new Term("name.first", "shay4")), Occur.SHOULD);
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
or.build());
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOrFilteredQuery2() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/or-filter2.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
BooleanQuery.Builder or = new BooleanQuery.Builder();
|
||||
or.add(new TermQuery(new Term("name.first", "shay1")), Occur.SHOULD);
|
||||
or.add(new TermQuery(new Term("name.first", "shay4")), Occur.SHOULD);
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
or.build());
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotFilteredQueryBuilder() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
Query parsedQuery = queryParser.parse(filteredQuery(matchAllQuery(), notQuery(termQuery("name.first", "shay1")))).query();
|
||||
BooleanQuery.Builder builder = new BooleanQuery.Builder();
|
||||
builder.add(new MatchAllDocsQuery(), Occur.MUST);
|
||||
builder.add(Queries.not(new TermQuery(new Term("name.first", "shay1"))), Occur.FILTER);
|
||||
assertEquals(builder.build(), parsedQuery);
|
||||
Query parsedQuery = queryParser.parse(notQuery(termQuery("name.first", "shay1"))).query();
|
||||
assertEquals(Queries.not(new TermQuery(new Term("name.first", "shay1"))), parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -944,9 +687,8 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/not-filter.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
Queries.not(new TermQuery(new Term("name.first", "shay1"))));
|
||||
Query expected =
|
||||
Queries.not(new TermQuery(new Term("name.first", "shay1")));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@ -955,9 +697,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/not-filter2.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
Queries.not(new TermQuery(new Term("name.first", "shay1"))));
|
||||
Query expected = Queries.not(new TermQuery(new Term("name.first", "shay1")));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@ -966,9 +706,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/not-filter3.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
Queries.not(new TermQuery(new Term("name.first", "shay1"))));
|
||||
Query expected = Queries.not(new TermQuery(new Term("name.first", "shay1")));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@ -1125,9 +863,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
public void testTermsFilterWithMultipleFields() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = XContentFactory.jsonBuilder().startObject()
|
||||
.startObject("filtered")
|
||||
.startObject("query").startObject("match_all").endObject().endObject()
|
||||
.startObject("filter").startObject("terms").array("foo", 123).array("bar", 456).endObject().endObject()
|
||||
.startObject("terms").array("foo", 123).array("bar", 456)
|
||||
.endObject().string();
|
||||
try {
|
||||
queryParser.parse(query).query();
|
||||
@ -1159,97 +895,6 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
assertThat(clauses[2].getOccur(), equalTo(BooleanClause.Occur.SHOULD));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilteredQueryBuilder() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
Query parsedQuery = queryParser.parse(filteredQuery(termQuery("name.first", "shay"), termQuery("name.last", "banon"))).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new TermQuery(new Term("name.last", "banon")));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilteredQuery() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/filtered-query.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new TermQuery(new Term("name.last", "banon")));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilteredQuery2() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/filtered-query2.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new TermQuery(new Term("name.last", "banon")));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilteredQuery3() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/filtered-query3.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
NumericRangeQuery.newLongRange("age", 23L, 54L, true, false));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilteredQuery4() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/filtered-query4.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
Query expectedQuery = new WildcardQuery(new Term("name.first", "sh*"));
|
||||
expectedQuery.setBoost(1.1f);
|
||||
Query expected = Queries.filtered(
|
||||
expectedQuery,
|
||||
new TermQuery(new Term("name.last", "banon")));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTermFilterQuery() throws Exception {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/term-filter.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new TermQuery(new Term("name.last", "banon")));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTermNamedFilterQuery() throws Exception {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/term-filter-named.json");
|
||||
ParsedQuery parsedQuery = queryParser.parse(query);
|
||||
assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true));
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new TermQuery(new Term("name.last", "banon")));
|
||||
assertEquals(expected, parsedQuery.query());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTermQueryParserShouldOnlyAllowSingleTerm() throws Exception {
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/term-filter-broken-multi-terms.json");
|
||||
assertQueryParsingFailureDueToMultipleTermsInTermFilter(query);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTermQueryParserShouldOnlyAllowSingleTermInAlternateFormat() throws Exception {
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/term-filter-broken-multi-terms-2.json");
|
||||
assertQueryParsingFailureDueToMultipleTermsInTermFilter(query);
|
||||
}
|
||||
|
||||
private void assertQueryParsingFailureDueToMultipleTermsInTermFilter(String query) throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
try {
|
||||
@ -1263,10 +908,8 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
@Test
|
||||
public void testTermsFilterQueryBuilder() throws Exception {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
Query parsedQuery = queryParser.parse(filteredQuery(termQuery("name.first", "shay"), termsQuery("name.last", "banon", "kimchy"))).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new TermsQuery("name.last", new BytesRef("banon"), new BytesRef("kimchy")));
|
||||
Query parsedQuery = queryParser.parse(constantScoreQuery(termsQuery("name.last", "banon", "kimchy"))).query();
|
||||
Query expected = new ConstantScoreQuery(new TermsQuery("name.last", new BytesRef("banon"), new BytesRef("kimchy")));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@ -1276,9 +919,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/terms-filter.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new TermsQuery("name.last", new BytesRef("banon"), new BytesRef("kimchy")));
|
||||
Query expected = new ConstantScoreQuery(new TermsQuery("name.last", new BytesRef("banon"), new BytesRef("kimchy")));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@ -1288,9 +929,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/terms-filter-named.json");
|
||||
ParsedQuery parsedQuery = queryParser.parse(query);
|
||||
assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true));
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new TermsQuery("name.last", new BytesRef("banon"), new BytesRef("kimchy")));
|
||||
Query expected = new ConstantScoreQuery(new TermsQuery("name.last", new BytesRef("banon"), new BytesRef("kimchy")));
|
||||
assertEquals(expected, parsedQuery.query());
|
||||
}
|
||||
|
||||
@ -1614,39 +1253,6 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
assertThat(wrapper, equalTo(new SpanMultiTermQueryWrapper<MultiTermQuery>(expectedWrapped)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryQueryBuilder() throws Exception {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
Query parsedQuery = queryParser.parse(filteredQuery(termQuery("name.first", "shay"), termQuery("name.last", "banon"))).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new TermQuery(new Term("name.last", "banon")));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryFilter() throws Exception {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/query-filter.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new ConstantScoreQuery(new TermQuery(new Term("name.last", "banon"))));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFQueryFilter() throws Exception {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/fquery-filter.json");
|
||||
ParsedQuery parsedQuery = queryParser.parse(query);
|
||||
assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true));
|
||||
Query expected = Queries.filtered(
|
||||
new TermQuery(new Term("name.first", "shay")),
|
||||
new ConstantScoreQuery(new TermQuery(new Term("name.last", "banon"))));
|
||||
assertEquals(expected, parsedQuery.query());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoreLikeThisBuilder() throws Exception {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
@ -1784,16 +1390,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance-named.json");
|
||||
ParsedQuery parsedQuery = queryParser.parse(query);
|
||||
assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true));
|
||||
assertThat(parsedQuery.query(), instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery.query();
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoDistanceRangeQuery.class));
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) booleanClause.getQuery();
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) parsedQuery.query();
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.lon(), closeTo(-70, 0.00001));
|
||||
@ -1806,16 +1403,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance1.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoDistanceRangeQuery.class));
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) booleanClause.getQuery();
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.lon(), closeTo(-70, 0.00001));
|
||||
@ -1828,16 +1416,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance2.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoDistanceRangeQuery.class));
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) booleanClause.getQuery();
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.lon(), closeTo(-70, 0.00001));
|
||||
@ -1850,16 +1429,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance3.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoDistanceRangeQuery.class));
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) booleanClause.getQuery();
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.lon(), closeTo(-70, 0.00001));
|
||||
@ -1872,16 +1442,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance4.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoDistanceRangeQuery.class));
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) booleanClause.getQuery();
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.lon(), closeTo(-70, 0.00001));
|
||||
@ -1894,16 +1455,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance5.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoDistanceRangeQuery.class));
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) booleanClause.getQuery();
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.lon(), closeTo(-70, 0.00001));
|
||||
@ -1916,16 +1468,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance6.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoDistanceRangeQuery.class));
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) booleanClause.getQuery();
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.lon(), closeTo(-70, 0.00001));
|
||||
@ -1938,16 +1481,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance7.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoDistanceRangeQuery.class));
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) booleanClause.getQuery();
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.lon(), closeTo(-70, 0.00001));
|
||||
@ -1960,16 +1494,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance8.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoDistanceRangeQuery.class));
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) booleanClause.getQuery();
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.lon(), closeTo(-70, 0.00001));
|
||||
@ -1982,16 +1507,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance9.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoDistanceRangeQuery.class));
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) booleanClause.getQuery();
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.lon(), closeTo(-70, 0.00001));
|
||||
@ -2004,16 +1520,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance10.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoDistanceRangeQuery.class));
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) booleanClause.getQuery();
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.lon(), closeTo(-70, 0.00001));
|
||||
@ -2026,16 +1533,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance11.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoDistanceRangeQuery.class));
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) booleanClause.getQuery();
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.lon(), closeTo(-70, 0.00001));
|
||||
@ -2048,16 +1546,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance12.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoDistanceRangeQuery.class));
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) booleanClause.getQuery();
|
||||
GeoDistanceRangeQuery filter = (GeoDistanceRangeQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.lon(), closeTo(-70, 0.00001));
|
||||
@ -2071,16 +1560,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_boundingbox-named.json");
|
||||
ParsedQuery parsedQuery = queryParser.parse(query);
|
||||
assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true));
|
||||
assertThat(parsedQuery.query(), instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery.query();
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(InMemoryGeoBoundingBoxQuery.class));
|
||||
InMemoryGeoBoundingBoxQuery filter = (InMemoryGeoBoundingBoxQuery) booleanClause.getQuery();
|
||||
InMemoryGeoBoundingBoxQuery filter = (InMemoryGeoBoundingBoxQuery) parsedQuery.query();
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.topLeft().lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.topLeft().lon(), closeTo(-70, 0.00001));
|
||||
@ -2093,16 +1573,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_boundingbox1.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(InMemoryGeoBoundingBoxQuery.class));
|
||||
InMemoryGeoBoundingBoxQuery filter = (InMemoryGeoBoundingBoxQuery) booleanClause.getQuery();
|
||||
InMemoryGeoBoundingBoxQuery filter = (InMemoryGeoBoundingBoxQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.topLeft().lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.topLeft().lon(), closeTo(-70, 0.00001));
|
||||
@ -2115,16 +1586,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_boundingbox2.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(InMemoryGeoBoundingBoxQuery.class));
|
||||
InMemoryGeoBoundingBoxQuery filter = (InMemoryGeoBoundingBoxQuery) booleanClause.getQuery();
|
||||
InMemoryGeoBoundingBoxQuery filter = (InMemoryGeoBoundingBoxQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.topLeft().lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.topLeft().lon(), closeTo(-70, 0.00001));
|
||||
@ -2137,16 +1599,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_boundingbox3.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(InMemoryGeoBoundingBoxQuery.class));
|
||||
InMemoryGeoBoundingBoxQuery filter = (InMemoryGeoBoundingBoxQuery) booleanClause.getQuery();
|
||||
InMemoryGeoBoundingBoxQuery filter = (InMemoryGeoBoundingBoxQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.topLeft().lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.topLeft().lon(), closeTo(-70, 0.00001));
|
||||
@ -2159,16 +1612,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_boundingbox4.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(InMemoryGeoBoundingBoxQuery.class));
|
||||
InMemoryGeoBoundingBoxQuery filter = (InMemoryGeoBoundingBoxQuery) booleanClause.getQuery();
|
||||
InMemoryGeoBoundingBoxQuery filter = (InMemoryGeoBoundingBoxQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.topLeft().lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.topLeft().lon(), closeTo(-70, 0.00001));
|
||||
@ -2181,16 +1625,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_boundingbox5.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(InMemoryGeoBoundingBoxQuery.class));
|
||||
InMemoryGeoBoundingBoxQuery filter = (InMemoryGeoBoundingBoxQuery) booleanClause.getQuery();
|
||||
InMemoryGeoBoundingBoxQuery filter = (InMemoryGeoBoundingBoxQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.topLeft().lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.topLeft().lon(), closeTo(-70, 0.00001));
|
||||
@ -2203,16 +1638,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_boundingbox6.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(InMemoryGeoBoundingBoxQuery.class));
|
||||
InMemoryGeoBoundingBoxQuery filter = (InMemoryGeoBoundingBoxQuery) booleanClause.getQuery();
|
||||
InMemoryGeoBoundingBoxQuery filter = (InMemoryGeoBoundingBoxQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.topLeft().lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.topLeft().lon(), closeTo(-70, 0.00001));
|
||||
@ -2227,16 +1653,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_polygon-named.json");
|
||||
ParsedQuery parsedQuery = queryParser.parse(query);
|
||||
assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true));
|
||||
assertThat(parsedQuery.query(), instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery.query();
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoPolygonQuery.class));
|
||||
GeoPolygonQuery filter = (GeoPolygonQuery) booleanClause.getQuery();
|
||||
GeoPolygonQuery filter = (GeoPolygonQuery) parsedQuery.query();
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.points().length, equalTo(4));
|
||||
assertThat(filter.points()[0].lat(), closeTo(40, 0.00001));
|
||||
@ -2275,16 +1692,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_polygon1.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoPolygonQuery.class));
|
||||
GeoPolygonQuery filter = (GeoPolygonQuery) booleanClause.getQuery();
|
||||
GeoPolygonQuery filter = (GeoPolygonQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.points().length, equalTo(4));
|
||||
assertThat(filter.points()[0].lat(), closeTo(40, 0.00001));
|
||||
@ -2300,16 +1708,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_polygon2.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoPolygonQuery.class));
|
||||
GeoPolygonQuery filter = (GeoPolygonQuery) booleanClause.getQuery();
|
||||
GeoPolygonQuery filter = (GeoPolygonQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.points().length, equalTo(4));
|
||||
assertThat(filter.points()[0].lat(), closeTo(40, 0.00001));
|
||||
@ -2325,16 +1724,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_polygon3.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoPolygonQuery.class));
|
||||
GeoPolygonQuery filter = (GeoPolygonQuery) booleanClause.getQuery();
|
||||
GeoPolygonQuery filter = (GeoPolygonQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.points().length, equalTo(4));
|
||||
assertThat(filter.points()[0].lat(), closeTo(40, 0.00001));
|
||||
@ -2350,16 +1740,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_polygon4.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(GeoPolygonQuery.class));
|
||||
GeoPolygonQuery filter = (GeoPolygonQuery) booleanClause.getQuery();
|
||||
GeoPolygonQuery filter = (GeoPolygonQuery) parsedQuery;
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.points().length, equalTo(4));
|
||||
assertThat(filter.points()[0].lat(), closeTo(40, 0.00001));
|
||||
@ -2375,15 +1756,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geoShape-filter.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(ConstantScoreQuery.class));
|
||||
ConstantScoreQuery constantScoreQuery = (ConstantScoreQuery) booleanClause.getQuery();
|
||||
ConstantScoreQuery constantScoreQuery = (ConstantScoreQuery) parsedQuery;
|
||||
assertThat(constantScoreQuery.getQuery(), instanceOf(IntersectsPrefixTreeFilter.class));
|
||||
}
|
||||
|
||||
@ -2573,16 +1946,6 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
assertThat(parsedQuery, instanceOf(MatchAllDocsQuery.class));
|
||||
}
|
||||
|
||||
// https://github.com/elasticsearch/elasticsearch/issues/7240
|
||||
@Test
|
||||
public void testEmptyBooleanQueryInsideFQuery() throws Exception {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/fquery-with-empty-bool-query.json");
|
||||
XContentParser parser = XContentHelper.createParser(new BytesArray(query));
|
||||
ParsedQuery parsedQuery = queryParser.parseInnerFilter(parser);
|
||||
assertEquals(new ConstantScoreQuery(Queries.filtered(new TermQuery(new Term("text", "apache")), new TermQuery(new Term("text", "apache")))), parsedQuery.query());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProperErrorMessageWhenTwoFunctionsDefinedInQueryBody() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
@ -2662,28 +2025,6 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
assertThat(e.getDetailedMessage(), containsString("you can either define [functions] array or a single function, not both. already found [weight], now encountering [functions]."));
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/elasticsearch/elasticsearch/issues/6722
|
||||
public void testEmptyBoolSubClausesIsMatchAll() throws IOException {
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/bool-query-with-empty-clauses-for-parsing.json");
|
||||
IndexService indexService = createIndex("testidx", client().admin().indices().prepareCreate("testidx")
|
||||
.addMapping("foo", "nested", "type=nested"));
|
||||
SearchContext.setCurrent(createSearchContext(indexService));
|
||||
IndexQueryParserService queryParser = indexService.queryParserService();
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) parsedQuery;
|
||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
||||
BooleanClause booleanClause = booleanQuery.clauses().get(0);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.MUST));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(MatchAllDocsQuery.class));
|
||||
booleanClause = booleanQuery.clauses().get(1);
|
||||
assertThat(booleanClause.getOccur(), equalTo(Occur.FILTER));
|
||||
assertThat(booleanClause.getQuery(), instanceOf(ToParentBlockJoinQuery.class));
|
||||
ToParentBlockJoinQuery toParentBlockJoinQuery = (ToParentBlockJoinQuery) booleanClause.getQuery();
|
||||
assertThat(toParentBlockJoinQuery.toString(), equalTo("ToParentBlockJoinQuery (+*:* #QueryWrapperFilter(_type:__nested))"));
|
||||
SearchContext.removeCurrent();
|
||||
}
|
||||
|
||||
/**
|
||||
* helper to extract term from TermQuery. */
|
||||
|
@ -130,7 +130,7 @@ public class SimpleNestedIT extends ESIntegTestCase {
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
|
||||
// filter
|
||||
searchResponse = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), nestedQuery("nested1",
|
||||
searchResponse = client().prepareSearch("test").setQuery(boolQuery().must(matchAllQuery()).mustNot(nestedQuery("nested1",
|
||||
boolQuery().must(termQuery("nested1.n_field1", "n_value1_1")).must(termQuery("nested1.n_field2", "n_value2_1"))))).execute().actionGet();
|
||||
assertNoFailures(searchResponse);
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
|
@ -1594,9 +1594,9 @@ public class PercolatorIT extends ESIntegTestCase {
|
||||
logger.info("--> register a query");
|
||||
client().prepareIndex("test", PercolatorService.TYPE_NAME, "1")
|
||||
.setSource(jsonBuilder().startObject()
|
||||
.field("query", QueryBuilders.constantScoreQuery(QueryBuilders.andQuery(
|
||||
QueryBuilders.queryStringQuery("root"),
|
||||
QueryBuilders.termQuery("message", "tree"))))
|
||||
.field("query", QueryBuilders.constantScoreQuery(QueryBuilders.boolQuery()
|
||||
.must(QueryBuilders.queryStringQuery("root"))
|
||||
.must(QueryBuilders.termQuery("message", "tree"))))
|
||||
.endObject())
|
||||
.setRefresh(true)
|
||||
.execute().actionGet();
|
||||
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch 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.search.aggregations.bucket;
|
||||
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
||||
import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
|
||||
public class DedicatedAggregationIT extends ESIntegTestCase {
|
||||
|
||||
// https://github.com/elasticsearch/elasticsearch/issues/7240
|
||||
@Test
|
||||
public void testEmptyBoolIsMatchAll() throws IOException {
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/search/aggregations/bucket/agg-filter-with-empty-bool.json");
|
||||
createIndex("testidx");
|
||||
index("testidx", "apache", "1", "field", "text");
|
||||
index("testidx", "nginx", "2", "field", "text");
|
||||
refresh();
|
||||
ensureGreen("testidx");
|
||||
SearchResponse searchResponse = client().prepareSearch("testidx").setQuery(matchAllQuery()).get();
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l));
|
||||
searchResponse = client().prepareSearch("testidx").setSource(query).get();
|
||||
assertSearchResponse(searchResponse);
|
||||
assertThat(searchResponse.getAggregations().getAsMap().get("issue7240"), instanceOf(Filter.class));
|
||||
Filter filterAgg = (Filter) searchResponse.getAggregations().getAsMap().get("issue7240");
|
||||
assertThat(filterAgg.getAggregations().getAsMap().get("terms"), instanceOf(StringTerms.class));
|
||||
assertThat(((StringTerms) filterAgg.getAggregations().getAsMap().get("terms")).getBuckets().get(0).getDocCount(), equalTo(1l));
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.AndQueryBuilder;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
|
||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||
@ -110,7 +110,7 @@ public class FilterIT extends ESIntegTestCase {
|
||||
// https://github.com/elasticsearch/elasticsearch/issues/8438
|
||||
@Test
|
||||
public void emptyFilterDeclarations() throws Exception {
|
||||
QueryBuilder emptyFilter = new AndQueryBuilder();
|
||||
QueryBuilder emptyFilter = new BoolQueryBuilder();
|
||||
SearchResponse response = client().prepareSearch("idx").addAggregation(filter("tag1").filter(emptyFilter)).execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
@ -23,7 +23,7 @@ import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.AndQueryBuilder;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.search.aggregations.bucket.filters.Filters;
|
||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||
@ -138,7 +138,7 @@ public class FiltersIT extends ESIntegTestCase {
|
||||
// https://github.com/elasticsearch/elasticsearch/issues/8438
|
||||
@Test
|
||||
public void emptyFilterDeclarations() throws Exception {
|
||||
QueryBuilder emptyFilter = new AndQueryBuilder();
|
||||
QueryBuilder emptyFilter = new BoolQueryBuilder();
|
||||
SearchResponse response = client().prepareSearch("idx")
|
||||
.addAggregation(filters("tags").filter("all", emptyFilter).filter("tag1", termQuery("tag", "tag1"))).execute()
|
||||
.actionGet();
|
||||
|
@ -62,7 +62,6 @@ import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.constantScoreQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.filteredQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.hasParentQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.idsQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
@ -133,25 +132,25 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
|
||||
SearchResponse searchResponse = client()
|
||||
.prepareSearch("test")
|
||||
.setQuery(
|
||||
filteredQuery(
|
||||
matchAllQuery(),
|
||||
hasChildQuery(
|
||||
boolQuery()
|
||||
.must(matchAllQuery())
|
||||
.filter(hasChildQuery(
|
||||
"child",
|
||||
filteredQuery(termQuery("c_field", "c_value1"),
|
||||
hasChildQuery("grandchild", termQuery("gc_field", "gc_value1")))))).get();
|
||||
boolQuery().must(termQuery("c_field", "c_value1"))
|
||||
.filter(hasChildQuery("grandchild", termQuery("gc_field", "gc_value1")))))).get();
|
||||
assertNoFailures(searchResponse);
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), hasParentQuery("parent", termQuery("p_field", "p_value1")))).execute()
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(hasParentQuery("parent", termQuery("p_field", "p_value1")))).execute()
|
||||
.actionGet();
|
||||
assertNoFailures(searchResponse);
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1"));
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), hasParentQuery("child", termQuery("c_field", "c_value1")))).execute()
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(hasParentQuery("child", termQuery("c_field", "c_value1")))).execute()
|
||||
.actionGet();
|
||||
assertNoFailures(searchResponse);
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
@ -170,25 +169,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("gc1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
// see #6722
|
||||
public void test6722() throws IOException {
|
||||
assertAcked(prepareCreate("test")
|
||||
.addMapping("foo")
|
||||
.addMapping("test", "_parent", "type=foo"));
|
||||
ensureGreen();
|
||||
|
||||
// index simple data
|
||||
client().prepareIndex("test", "foo", "1").setSource("foo", 1).get();
|
||||
client().prepareIndex("test", "test", "2").setSource("foo", 1).setParent("1").get();
|
||||
refresh();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/search/child/bool-query-with-empty-clauses.json");
|
||||
SearchResponse searchResponse = client().prepareSearch("test").setSource(query).get();
|
||||
assertNoFailures(searchResponse);
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
// see #2744
|
||||
public void test2744() throws IOException {
|
||||
@ -553,12 +533,12 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
|
||||
client().admin().indices().prepareFlush("test").get();
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), hasChildQuery("child", matchAllQuery()))).get();
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(hasChildQuery("child", matchAllQuery()))).get();
|
||||
assertNoFailures(searchResponse);
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), hasParentQuery("parent", matchAllQuery()))).get();
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(hasParentQuery("parent", matchAllQuery()))).get();
|
||||
assertNoFailures(searchResponse);
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
}
|
||||
@ -818,13 +798,13 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
|
||||
client().admin().indices().prepareFlush("test").get();
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), hasChildQuery("child", termQuery("c_field", 1)))).get();
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(hasChildQuery("child", termQuery("c_field", 1)))).get();
|
||||
assertNoFailures(searchResponse);
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
assertThat(searchResponse.getHits().hits()[0].id(), equalTo("1"));
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), hasParentQuery("parent", termQuery("p_field", 1)))).get();
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(hasParentQuery("parent", termQuery("p_field", 1)))).get();
|
||||
assertNoFailures(searchResponse);
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
assertThat(searchResponse.getHits().hits()[0].id(), equalTo("2"));
|
||||
@ -844,19 +824,19 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
|
||||
refresh();
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), hasChildQuery("child", matchQuery("c_field", 1)))).get();
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(hasChildQuery("child", matchQuery("c_field", 1)))).get();
|
||||
assertSearchHit(searchResponse, 1, hasId("1"));
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), hasParentQuery("parent", matchQuery("p_field", 1)))).get();
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(hasParentQuery("parent", matchQuery("p_field", 1)))).get();
|
||||
assertSearchHit(searchResponse, 1, hasId("2"));
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), boolQuery().must(hasChildQuery("child", matchQuery("c_field", 1))))).get();
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(boolQuery().must(hasChildQuery("child", matchQuery("c_field", 1))))).get();
|
||||
assertSearchHit(searchResponse, 1, hasId("1"));
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), boolQuery().must(hasParentQuery("parent", matchQuery("p_field", 1))))).get();
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(boolQuery().must(hasParentQuery("parent", matchQuery("p_field", 1))))).get();
|
||||
assertSearchHit(searchResponse, 1, hasId("2"));
|
||||
}
|
||||
|
||||
@ -1008,7 +988,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
|
||||
ensureGreen();
|
||||
|
||||
// test term filter
|
||||
SearchResponse response = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termQuery("_parent", "p1")))
|
||||
SearchResponse response = client().prepareSearch("test").setQuery(boolQuery().must(matchAllQuery()).filter(termQuery("_parent", "p1")))
|
||||
.get();
|
||||
assertHitCount(response, 0l);
|
||||
|
||||
@ -1016,51 +996,51 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
|
||||
client().prepareIndex("test", "parent", "p1").setSource("p_field", "value").get();
|
||||
client().prepareIndex("test", "child", "c1").setSource("c_field", "value").setParent("p1").get();
|
||||
|
||||
response = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termQuery("_parent", "p1"))).execute()
|
||||
response = client().prepareSearch("test").setQuery(boolQuery().must(matchAllQuery()).filter(termQuery("_parent", "p1"))).execute()
|
||||
.actionGet();
|
||||
assertHitCount(response, 0l);
|
||||
refresh();
|
||||
|
||||
response = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termQuery("_parent", "p1"))).execute()
|
||||
response = client().prepareSearch("test").setQuery(boolQuery().must(matchAllQuery()).filter(termQuery("_parent", "p1"))).execute()
|
||||
.actionGet();
|
||||
assertHitCount(response, 1l);
|
||||
|
||||
response = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termQuery("_parent", "parent#p1"))).execute()
|
||||
response = client().prepareSearch("test").setQuery(boolQuery().must(matchAllQuery()).filter(termQuery("_parent", "parent#p1"))).execute()
|
||||
.actionGet();
|
||||
assertHitCount(response, 1l);
|
||||
|
||||
client().prepareIndex("test", "parent2", "p1").setSource("p_field", "value").setRefresh(true).get();
|
||||
|
||||
response = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termQuery("_parent", "p1"))).execute()
|
||||
response = client().prepareSearch("test").setQuery(boolQuery().must(matchAllQuery()).filter(termQuery("_parent", "p1"))).execute()
|
||||
.actionGet();
|
||||
assertHitCount(response, 1l);
|
||||
|
||||
response = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termQuery("_parent", "parent#p1"))).execute()
|
||||
response = client().prepareSearch("test").setQuery(boolQuery().must(matchAllQuery()).filter(termQuery("_parent", "parent#p1"))).execute()
|
||||
.actionGet();
|
||||
assertHitCount(response, 1l);
|
||||
|
||||
// test terms filter
|
||||
client().prepareIndex("test", "child2", "c1").setSource("c_field", "value").setParent("p1").get();
|
||||
response = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termsQuery("_parent", "p1"))).execute()
|
||||
response = client().prepareSearch("test").setQuery(boolQuery().must(matchAllQuery()).filter(termsQuery("_parent", "p1"))).execute()
|
||||
.actionGet();
|
||||
assertHitCount(response, 1l);
|
||||
|
||||
response = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termsQuery("_parent", "parent#p1"))).execute()
|
||||
response = client().prepareSearch("test").setQuery(boolQuery().must(matchAllQuery()).filter(termsQuery("_parent", "parent#p1"))).execute()
|
||||
.actionGet();
|
||||
assertHitCount(response, 1l);
|
||||
|
||||
refresh();
|
||||
response = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termsQuery("_parent", "p1"))).execute()
|
||||
response = client().prepareSearch("test").setQuery(boolQuery().must(matchAllQuery()).filter(termsQuery("_parent", "p1"))).execute()
|
||||
.actionGet();
|
||||
assertHitCount(response, 2l);
|
||||
|
||||
refresh();
|
||||
response = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termsQuery("_parent", "p1", "p1"))).execute()
|
||||
response = client().prepareSearch("test").setQuery(boolQuery().must(matchAllQuery()).filter(termsQuery("_parent", "p1", "p1"))).execute()
|
||||
.actionGet();
|
||||
assertHitCount(response, 2l);
|
||||
|
||||
response = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("_parent", "parent#p1", "parent2#p1"))).get();
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(termsQuery("_parent", "parent#p1", "parent2#p1"))).get();
|
||||
assertHitCount(response, 2l);
|
||||
}
|
||||
|
||||
@ -1107,7 +1087,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
|
||||
if (randomBoolean()) {
|
||||
return constantScoreQuery(hasChildQuery(type, termQuery(field, value)));
|
||||
} else {
|
||||
return filteredQuery(matchAllQuery(), hasChildQuery(type, termQuery(field, value)));
|
||||
return boolQuery().must(matchAllQuery()).filter(hasChildQuery(type, termQuery(field, value)));
|
||||
}
|
||||
} else {
|
||||
return hasChildQuery(type, termQuery(field, value));
|
||||
@ -1119,7 +1099,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
|
||||
if (randomBoolean()) {
|
||||
return constantScoreQuery(hasParentQuery(type, termQuery(field, value)));
|
||||
} else {
|
||||
return filteredQuery(matchAllQuery(), hasParentQuery(type, termQuery(field, value)));
|
||||
return boolQuery().must(matchAllQuery()).filter(hasParentQuery(type, termQuery(field, value)));
|
||||
}
|
||||
} else {
|
||||
return hasParentQuery(type, termQuery(field, value));
|
||||
@ -1259,13 +1239,13 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
|
||||
|
||||
String scoreMode = ScoreType.values()[getRandom().nextInt(ScoreType.values().length)].name().toLowerCase(Locale.ROOT);
|
||||
SearchResponse searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(QueryBuilders.hasChildQuery("child", termQuery("c_field", "blue")).scoreType(scoreMode), notQuery(termQuery("p_field", "3"))))
|
||||
.setQuery(boolQuery().must(QueryBuilders.hasChildQuery("child", termQuery("c_field", "blue")).scoreType(scoreMode)).filter(notQuery(termQuery("p_field", "3"))))
|
||||
.get();
|
||||
assertNoFailures(searchResponse);
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(QueryBuilders.hasChildQuery("child", termQuery("c_field", "red")).scoreType(scoreMode), notQuery(termQuery("p_field", "3"))))
|
||||
.setQuery(boolQuery().must(QueryBuilders.hasChildQuery("child", termQuery("c_field", "red")).scoreType(scoreMode)).filter(notQuery(termQuery("p_field", "3"))))
|
||||
.get();
|
||||
assertNoFailures(searchResponse);
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
|
||||
@ -1419,7 +1399,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
SearchResponse searchResponse = client().prepareSearch()
|
||||
.setQuery(filteredQuery(matchAllQuery(), boolQuery()
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(boolQuery()
|
||||
.must(QueryBuilders.hasChildQuery("child", matchQuery("c_field", "red")))
|
||||
.must(matchAllQuery())))
|
||||
.get();
|
||||
@ -1431,7 +1411,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
|
||||
client().admin().indices().prepareRefresh("test").get();
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch()
|
||||
.setQuery(filteredQuery(matchAllQuery(), boolQuery()
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(boolQuery()
|
||||
.must(QueryBuilders.hasChildQuery("child", matchQuery("c_field", "red")))
|
||||
.must(matchAllQuery())))
|
||||
.get();
|
||||
@ -1454,9 +1434,9 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
|
||||
|
||||
QueryBuilder[] queries = new QueryBuilder[]{
|
||||
hasChildQuery("child", matchAllQuery()),
|
||||
filteredQuery(matchAllQuery(), hasChildQuery("child", matchAllQuery())),
|
||||
boolQuery().must(matchAllQuery()).filter(hasChildQuery("child", matchAllQuery())),
|
||||
hasParentQuery("parent", matchAllQuery()),
|
||||
filteredQuery(matchAllQuery(), hasParentQuery("parent", matchAllQuery()))
|
||||
boolQuery().must(matchAllQuery()).filter(hasParentQuery("parent", matchAllQuery()))
|
||||
};
|
||||
|
||||
for (QueryBuilder query : queries) {
|
||||
|
@ -26,8 +26,9 @@ import org.elasticsearch.search.SearchHit;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.geoBoundingBoxQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
import static org.hamcrest.Matchers.anyOf;
|
||||
@ -90,7 +91,7 @@ public class GeoBoundingBoxIT extends ESIntegTestCase {
|
||||
client().admin().indices().prepareRefresh().execute().actionGet();
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch() // from NY
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoBoundingBoxQuery("location").topLeft(40.73, -74.1).bottomRight(40.717, -73.99)))
|
||||
.setQuery(geoBoundingBoxQuery("location").topLeft(40.73, -74.1).bottomRight(40.717, -73.99))
|
||||
.execute().actionGet();
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l));
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(2));
|
||||
@ -99,7 +100,7 @@ public class GeoBoundingBoxIT extends ESIntegTestCase {
|
||||
}
|
||||
|
||||
searchResponse = client().prepareSearch() // from NY
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoBoundingBoxQuery("location").topLeft(40.73, -74.1).bottomRight(40.717, -73.99).type("indexed")))
|
||||
.setQuery(geoBoundingBoxQuery("location").topLeft(40.73, -74.1).bottomRight(40.717, -73.99).type("indexed"))
|
||||
.execute().actionGet();
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l));
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(2));
|
||||
@ -159,52 +160,52 @@ public class GeoBoundingBoxIT extends ESIntegTestCase {
|
||||
refresh();
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch()
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoBoundingBoxQuery("location").topLeft(41, -11).bottomRight(40, 9)))
|
||||
.setQuery(geoBoundingBoxQuery("location").topLeft(41, -11).bottomRight(40, 9))
|
||||
.execute().actionGet();
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l));
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(1));
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("2"));
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoBoundingBoxQuery("location").topLeft(41, -11).bottomRight(40, 9).type("indexed")))
|
||||
.setQuery(geoBoundingBoxQuery("location").topLeft(41, -11).bottomRight(40, 9).type("indexed"))
|
||||
.execute().actionGet();
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l));
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(1));
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("2"));
|
||||
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoBoundingBoxQuery("location").topLeft(41, -9).bottomRight(40, 11)))
|
||||
.setQuery(geoBoundingBoxQuery("location").topLeft(41, -9).bottomRight(40, 11))
|
||||
.execute().actionGet();
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l));
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(1));
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("3"));
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoBoundingBoxQuery("location").topLeft(41, -9).bottomRight(40, 11).type("indexed")))
|
||||
.setQuery(geoBoundingBoxQuery("location").topLeft(41, -9).bottomRight(40, 11).type("indexed"))
|
||||
.execute().actionGet();
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l));
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(1));
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("3"));
|
||||
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoBoundingBoxQuery("location").topLeft(11, 171).bottomRight(1, -169)))
|
||||
.setQuery(geoBoundingBoxQuery("location").topLeft(11, 171).bottomRight(1, -169))
|
||||
.execute().actionGet();
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l));
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(1));
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("5"));
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoBoundingBoxQuery("location").topLeft(11, 171).bottomRight(1, -169).type("indexed")))
|
||||
.setQuery(geoBoundingBoxQuery("location").topLeft(11, 171).bottomRight(1, -169).type("indexed"))
|
||||
.execute().actionGet();
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l));
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(1));
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("5"));
|
||||
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoBoundingBoxQuery("location").topLeft(9, 169).bottomRight(-1, -171)))
|
||||
.setQuery(geoBoundingBoxQuery("location").topLeft(9, 169).bottomRight(-1, -171))
|
||||
.execute().actionGet();
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l));
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(1));
|
||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("9"));
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoBoundingBoxQuery("location").topLeft(9, 169).bottomRight(-1, -171).type("indexed")))
|
||||
.setQuery(geoBoundingBoxQuery("location").topLeft(9, 169).bottomRight(-1, -171).type("indexed"))
|
||||
.execute().actionGet();
|
||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l));
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(1));
|
||||
@ -237,26 +238,26 @@ public class GeoBoundingBoxIT extends ESIntegTestCase {
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch()
|
||||
.setQuery(
|
||||
filteredQuery(termQuery("userid", 880),
|
||||
boolQuery().must(termQuery("userid", 880)).filter(
|
||||
geoBoundingBoxQuery("location").topLeft(74.579421999999994, 143.5).bottomRight(-66.668903999999998, 113.96875))
|
||||
).execute().actionGet();
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(
|
||||
filteredQuery(termQuery("userid", 880),
|
||||
boolQuery().must(termQuery("userid", 880)).filter(
|
||||
geoBoundingBoxQuery("location").topLeft(74.579421999999994, 143.5).bottomRight(-66.668903999999998, 113.96875).type("indexed"))
|
||||
).execute().actionGet();
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(
|
||||
filteredQuery(termQuery("userid", 534),
|
||||
boolQuery().must(termQuery("userid", 534)).filter(
|
||||
geoBoundingBoxQuery("location").topLeft(74.579421999999994, 143.5).bottomRight(-66.668903999999998, 113.96875))
|
||||
).execute().actionGet();
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(
|
||||
filteredQuery(termQuery("userid", 534),
|
||||
boolQuery().must(termQuery("userid", 534)).filter(
|
||||
geoBoundingBoxQuery("location").topLeft(74.579421999999994, 143.5).bottomRight(-66.668903999999998, 113.96875).type("indexed"))
|
||||
).execute().actionGet();
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
@ -288,51 +289,43 @@ public class GeoBoundingBoxIT extends ESIntegTestCase {
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch()
|
||||
.setQuery(
|
||||
filteredQuery(matchAllQuery(),
|
||||
geoBoundingBoxQuery("location").coerce(true).topLeft(50, -180).bottomRight(-50, 180))
|
||||
geoBoundingBoxQuery("location").coerce(true).topLeft(50, -180).bottomRight(-50, 180)
|
||||
).execute().actionGet();
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(
|
||||
filteredQuery(matchAllQuery(),
|
||||
geoBoundingBoxQuery("location").coerce(true).topLeft(50, -180).bottomRight(-50, 180).type("indexed"))
|
||||
geoBoundingBoxQuery("location").coerce(true).topLeft(50, -180).bottomRight(-50, 180).type("indexed")
|
||||
).execute().actionGet();
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(
|
||||
filteredQuery(matchAllQuery(),
|
||||
geoBoundingBoxQuery("location").coerce(true).topLeft(90, -180).bottomRight(-90, 180))
|
||||
geoBoundingBoxQuery("location").coerce(true).topLeft(90, -180).bottomRight(-90, 180)
|
||||
).execute().actionGet();
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(
|
||||
filteredQuery(matchAllQuery(),
|
||||
geoBoundingBoxQuery("location").coerce(true).topLeft(90, -180).bottomRight(-90, 180).type("indexed"))
|
||||
geoBoundingBoxQuery("location").coerce(true).topLeft(90, -180).bottomRight(-90, 180).type("indexed")
|
||||
).execute().actionGet();
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
|
||||
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(
|
||||
filteredQuery(matchAllQuery(),
|
||||
geoBoundingBoxQuery("location").coerce(true).topLeft(50, 0).bottomRight(-50, 360))
|
||||
geoBoundingBoxQuery("location").coerce(true).topLeft(50, 0).bottomRight(-50, 360)
|
||||
).execute().actionGet();
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(
|
||||
filteredQuery(matchAllQuery(),
|
||||
geoBoundingBoxQuery("location").coerce(true).topLeft(50, 0).bottomRight(-50, 360).type("indexed"))
|
||||
geoBoundingBoxQuery("location").coerce(true).topLeft(50, 0).bottomRight(-50, 360).type("indexed")
|
||||
).execute().actionGet();
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(
|
||||
filteredQuery(matchAllQuery(),
|
||||
geoBoundingBoxQuery("location").coerce(true).topLeft(90, 0).bottomRight(-90, 360))
|
||||
geoBoundingBoxQuery("location").coerce(true).topLeft(90, 0).bottomRight(-90, 360)
|
||||
).execute().actionGet();
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
|
||||
searchResponse = client().prepareSearch()
|
||||
.setQuery(
|
||||
filteredQuery(matchAllQuery(),
|
||||
geoBoundingBoxQuery("location").coerce(true).topLeft(90, 0).bottomRight(-90, 360).type("indexed"))
|
||||
geoBoundingBoxQuery("location").coerce(true).topLeft(90, 0).bottomRight(-90, 360).type("indexed")
|
||||
).execute().actionGet();
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.filteredQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.geoDistanceQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.geoDistanceRangeQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
@ -109,7 +108,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||
.endObject()));
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch() // from NY
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoDistanceQuery("location").distance("3km").point(40.7143528, -74.0059731)))
|
||||
.setQuery(geoDistanceQuery("location").distance("3km").point(40.7143528, -74.0059731))
|
||||
.execute().actionGet();
|
||||
assertHitCount(searchResponse, 5);
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(5));
|
||||
@ -117,7 +116,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||
assertThat(hit.id(), anyOf(equalTo("1"), equalTo("3"), equalTo("4"), equalTo("5"), equalTo("6")));
|
||||
}
|
||||
searchResponse = client().prepareSearch() // from NY
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoDistanceQuery("location").distance("3km").point(40.7143528, -74.0059731).optimizeBbox("indexed")))
|
||||
.setQuery(geoDistanceQuery("location").distance("3km").point(40.7143528, -74.0059731).optimizeBbox("indexed"))
|
||||
.execute().actionGet();
|
||||
assertHitCount(searchResponse, 5);
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(5));
|
||||
@ -127,7 +126,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||
|
||||
// now with a PLANE type
|
||||
searchResponse = client().prepareSearch() // from NY
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoDistanceQuery("location").distance("3km").geoDistance(GeoDistance.PLANE).point(40.7143528, -74.0059731)))
|
||||
.setQuery(geoDistanceQuery("location").distance("3km").geoDistance(GeoDistance.PLANE).point(40.7143528, -74.0059731))
|
||||
.execute().actionGet();
|
||||
assertHitCount(searchResponse, 5);
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(5));
|
||||
@ -138,7 +137,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||
// factor type is really too small for this resolution
|
||||
|
||||
searchResponse = client().prepareSearch() // from NY
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoDistanceQuery("location").distance("2km").point(40.7143528, -74.0059731)))
|
||||
.setQuery(geoDistanceQuery("location").distance("2km").point(40.7143528, -74.0059731))
|
||||
.execute().actionGet();
|
||||
assertHitCount(searchResponse, 4);
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(4));
|
||||
@ -146,7 +145,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||
assertThat(hit.id(), anyOf(equalTo("1"), equalTo("3"), equalTo("4"), equalTo("5")));
|
||||
}
|
||||
searchResponse = client().prepareSearch() // from NY
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoDistanceQuery("location").distance("2km").point(40.7143528, -74.0059731).optimizeBbox("indexed")))
|
||||
.setQuery(geoDistanceQuery("location").distance("2km").point(40.7143528, -74.0059731).optimizeBbox("indexed"))
|
||||
.execute().actionGet();
|
||||
assertHitCount(searchResponse, 4);
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(4));
|
||||
@ -155,7 +154,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||
}
|
||||
|
||||
searchResponse = client().prepareSearch() // from NY
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoDistanceQuery("location").distance("1.242mi").point(40.7143528, -74.0059731)))
|
||||
.setQuery(geoDistanceQuery("location").distance("1.242mi").point(40.7143528, -74.0059731))
|
||||
.execute().actionGet();
|
||||
assertHitCount(searchResponse, 4);
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(4));
|
||||
@ -163,7 +162,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||
assertThat(hit.id(), anyOf(equalTo("1"), equalTo("3"), equalTo("4"), equalTo("5")));
|
||||
}
|
||||
searchResponse = client().prepareSearch() // from NY
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoDistanceQuery("location").distance("1.242mi").point(40.7143528, -74.0059731).optimizeBbox("indexed")))
|
||||
.setQuery(geoDistanceQuery("location").distance("1.242mi").point(40.7143528, -74.0059731).optimizeBbox("indexed"))
|
||||
.execute().actionGet();
|
||||
assertHitCount(searchResponse, 4);
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(4));
|
||||
@ -172,7 +171,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||
}
|
||||
|
||||
searchResponse = client().prepareSearch() // from NY
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoDistanceRangeQuery("location").from("1.0km").to("2.0km").point(40.7143528, -74.0059731)))
|
||||
.setQuery(geoDistanceRangeQuery("location").from("1.0km").to("2.0km").point(40.7143528, -74.0059731))
|
||||
.execute().actionGet();
|
||||
assertHitCount(searchResponse, 2);
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(2));
|
||||
@ -180,7 +179,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||
assertThat(hit.id(), anyOf(equalTo("4"), equalTo("5")));
|
||||
}
|
||||
searchResponse = client().prepareSearch() // from NY
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoDistanceRangeQuery("location").from("1.0km").to("2.0km").point(40.7143528, -74.0059731).optimizeBbox("indexed")))
|
||||
.setQuery(geoDistanceRangeQuery("location").from("1.0km").to("2.0km").point(40.7143528, -74.0059731).optimizeBbox("indexed"))
|
||||
.execute().actionGet();
|
||||
assertHitCount(searchResponse, 2);
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(2));
|
||||
@ -189,13 +188,13 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
||||
}
|
||||
|
||||
searchResponse = client().prepareSearch() // from NY
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoDistanceRangeQuery("location").to("2.0km").point(40.7143528, -74.0059731)))
|
||||
.setQuery(geoDistanceRangeQuery("location").to("2.0km").point(40.7143528, -74.0059731))
|
||||
.execute().actionGet();
|
||||
assertHitCount(searchResponse, 4);
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(4));
|
||||
|
||||
searchResponse = client().prepareSearch() // from NY
|
||||
.setQuery(filteredQuery(matchAllQuery(), geoDistanceRangeQuery("location").from("2.0km").point(40.7143528, -74.0059731)))
|
||||
.setQuery(geoDistanceRangeQuery("location").from("2.0km").point(40.7143528, -74.0059731))
|
||||
.execute().actionGet();
|
||||
assertHitCount(searchResponse, 3);
|
||||
assertThat(searchResponse.getHits().hits().length, equalTo(3));
|
||||
|
@ -427,20 +427,16 @@ public class GeoFilterIT extends ESIntegTestCase {
|
||||
}
|
||||
|
||||
SearchResponse world = client().prepareSearch().addField("pin").setQuery(
|
||||
filteredQuery(
|
||||
matchAllQuery(),
|
||||
geoBoundingBoxQuery("pin")
|
||||
.topLeft(90, -179.99999)
|
||||
.bottomRight(-90, 179.99999))
|
||||
geoBoundingBoxQuery("pin")
|
||||
.topLeft(90, -179.99999)
|
||||
.bottomRight(-90, 179.99999)
|
||||
).execute().actionGet();
|
||||
|
||||
assertHitCount(world, 53);
|
||||
|
||||
SearchResponse distance = client().prepareSearch().addField("pin").setQuery(
|
||||
filteredQuery(
|
||||
matchAllQuery(),
|
||||
geoDistanceQuery("pin").distance("425km").point(51.11, 9.851)
|
||||
)).execute().actionGet();
|
||||
geoDistanceQuery("pin").distance("425km").point(51.11, 9.851)
|
||||
).execute().actionGet();
|
||||
|
||||
assertHitCount(distance, 5);
|
||||
GeoPoint point = new GeoPoint();
|
||||
|
@ -43,10 +43,8 @@ import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.filteredQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.geoIntersectionQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.geoShapeQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
|
||||
@ -101,8 +99,7 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
|
||||
ShapeBuilder shape = ShapeBuilder.newEnvelope().topLeft(-45, 45).bottomRight(45, -45);
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch()
|
||||
.setQuery(filteredQuery(matchAllQuery(),
|
||||
geoIntersectionQuery("location", shape)))
|
||||
.setQuery(geoIntersectionQuery("location", shape))
|
||||
.execute().actionGet();
|
||||
|
||||
assertSearchResponse(searchResponse);
|
||||
@ -151,8 +148,7 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
|
||||
// This search would fail if both geoshape indexing and geoshape filtering
|
||||
// used the bottom-level optimization in SpatialPrefixTree#recursiveGetNodes.
|
||||
SearchResponse searchResponse = client().prepareSearch()
|
||||
.setQuery(filteredQuery(matchAllQuery(),
|
||||
geoIntersectionQuery("location", query)))
|
||||
.setQuery(geoIntersectionQuery("location", query))
|
||||
.execute().actionGet();
|
||||
|
||||
assertSearchResponse(searchResponse);
|
||||
@ -187,8 +183,7 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
|
||||
.endObject()));
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(),
|
||||
geoIntersectionQuery("location", "Big_Rectangle", "shape_type")))
|
||||
.setQuery(geoIntersectionQuery("location", "Big_Rectangle", "shape_type"))
|
||||
.execute().actionGet();
|
||||
|
||||
assertSearchResponse(searchResponse);
|
||||
|
@ -55,7 +55,6 @@ import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.boostingQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.commonTermsQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.constantScoreQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.filteredQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.fuzzyQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchPhrasePrefixQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchPhraseQuery;
|
||||
@ -2488,7 +2487,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
|
||||
SearchSourceBuilder source = searchSource().query(boolQuery()
|
||||
.should(constantScoreQuery(QueryBuilders.missingQuery("field1")))
|
||||
.should(matchQuery("field1", "test"))
|
||||
.should(filteredQuery(queryStringQuery("field1:photo*"), null)))
|
||||
.should(constantScoreQuery(queryStringQuery("field1:photo*"))))
|
||||
.highlight(highlight().field("field1"));
|
||||
SearchResponse searchResponse = client().prepareSearch("test").setSource(source.buildAsBytes()).get();
|
||||
assertHighlight(searchResponse, 0, "field1", 0, 1, equalTo("The <em>photography</em> word will get highlighted"));
|
||||
@ -2520,7 +2519,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
|
||||
refresh();
|
||||
|
||||
logger.info("--> highlighting and searching on field1");
|
||||
SearchSourceBuilder source = searchSource().query(filteredQuery(queryStringQuery("field1:photo*"), missingQuery("field_null")))
|
||||
SearchSourceBuilder source = searchSource().query(boolQuery().must(queryStringQuery("field1:photo*")).filter(missingQuery("field_null")))
|
||||
.highlight(highlight().field("field1"));
|
||||
SearchResponse searchResponse = client().prepareSearch("test").setSource(source.buildAsBytes()).get();
|
||||
assertHighlight(searchResponse, 0, "field1", 0, 1, equalTo("The <em>photography</em> word will get highlighted"));
|
||||
|
@ -47,7 +47,7 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||
refresh();
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch()
|
||||
.setQuery(filteredQuery(matchAllQuery(), orQuery(rangeQuery("number").lte(2).queryName("test1"), rangeQuery("number").gt(2).queryName("test2")))).get();
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(boolQuery().should(rangeQuery("number").lte(2).queryName("test1")).should(rangeQuery("number").gt(2).queryName("test2")))).get();
|
||||
assertHitCount(searchResponse, 3l);
|
||||
for (SearchHit hit : searchResponse.getHits()) {
|
||||
if (hit.id().equals("1") || hit.id().equals("2")) {
|
||||
@ -89,8 +89,8 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch()
|
||||
.setQuery(matchAllQuery())
|
||||
.setPostFilter(orQuery(
|
||||
termQuery("name", "test").queryName("name"),
|
||||
.setPostFilter(boolQuery().should(
|
||||
termQuery("name", "test").queryName("name")).should(
|
||||
termQuery("title", "title1").queryName("title"))).get();
|
||||
assertHitCount(searchResponse, 3l);
|
||||
for (SearchHit hit : searchResponse.getHits()) {
|
||||
@ -138,7 +138,7 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||
refresh();
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch()
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("title", "title1", "title2", "title3").queryName("title")))
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(termsQuery("title", "title1", "title2", "title3").queryName("title")))
|
||||
.setPostFilter(termQuery("name", "test").queryName("name")).get();
|
||||
assertHitCount(searchResponse, 3l);
|
||||
for (SearchHit hit : searchResponse.getHits()) {
|
||||
@ -177,10 +177,10 @@ public class MatchedQueriesIT extends ESIntegTestCase {
|
||||
refresh();
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch()
|
||||
.setQuery(filteredQuery(matchAllQuery(),
|
||||
orQuery(
|
||||
.setQuery(boolQuery().must(matchAllQuery()).filter(
|
||||
boolQuery().should(
|
||||
indicesQuery(termQuery("title", "title1").queryName("title1"), "test1")
|
||||
.noMatchQuery(termQuery("title", "title2").queryName("title2")).queryName("indices_filter"),
|
||||
.noMatchQuery(termQuery("title", "title2").queryName("title2")).queryName("indices_filter")).should(
|
||||
termQuery("title", "title3").queryName("title3")).queryName("or"))).get();
|
||||
assertHitCount(searchResponse, 3l);
|
||||
|
||||
|
@ -53,9 +53,7 @@ import org.joda.time.format.ISODateTimeFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
|
||||
@ -151,18 +149,18 @@ public class SearchQueryIT extends ESIntegTestCase {
|
||||
client().prepareSearch()
|
||||
.setQuery(matchAllQuery())
|
||||
.setPostFilter(
|
||||
andQuery(
|
||||
matchAllQuery(),
|
||||
notQuery(andQuery(termQuery("field1", "value1"),
|
||||
boolQuery().must(
|
||||
matchAllQuery()).must(
|
||||
notQuery(boolQuery().must(termQuery("field1", "value1")).must(
|
||||
termQuery("field1", "value2"))))).get(),
|
||||
3l);
|
||||
assertHitCount(
|
||||
client().prepareSearch()
|
||||
.setQuery(
|
||||
filteredQuery(
|
||||
boolQuery().must(
|
||||
boolQuery().should(termQuery("field1", "value1")).should(termQuery("field1", "value2"))
|
||||
.should(termQuery("field1", "value3")),
|
||||
notQuery(andQuery(termQuery("field1", "value1"),
|
||||
.should(termQuery("field1", "value3"))).filter(
|
||||
notQuery(boolQuery().must(termQuery("field1", "value1")).must(
|
||||
termQuery("field1", "value2"))))).get(),
|
||||
3l);
|
||||
assertHitCount(
|
||||
@ -662,8 +660,8 @@ public class SearchQueryIT extends ESIntegTestCase {
|
||||
client().prepareIndex("test", "type2", "2").setSource("field1", "value1"),
|
||||
client().prepareIndex("test", "type2", "3").setSource("field1", "value1"));
|
||||
|
||||
assertHitCount(client().prepareSearch().setQuery(filteredQuery(matchAllQuery(), typeQuery("type1"))).get(), 2l);
|
||||
assertHitCount(client().prepareSearch().setQuery(filteredQuery(matchAllQuery(), typeQuery("type2"))).get(), 3l);
|
||||
assertHitCount(client().prepareSearch().setQuery(typeQuery("type1")).get(), 2l);
|
||||
assertHitCount(client().prepareSearch().setQuery(typeQuery("type2")).get(), 3l);
|
||||
|
||||
assertHitCount(client().prepareSearch().setTypes("type1").setQuery(matchAllQuery()).get(), 2l);
|
||||
assertHitCount(client().prepareSearch().setTypes("type2").setQuery(matchAllQuery()).get(), 3l);
|
||||
@ -772,19 +770,6 @@ public class SearchQueryIT extends ESIntegTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLimitFilter() throws Exception {
|
||||
assertAcked(client().admin().indices().prepareCreate("test").setSettings(SETTING_NUMBER_OF_SHARDS, 1));
|
||||
|
||||
indexRandom(true, client().prepareIndex("test", "type1", "1").setSource("field1", "value1_1"),
|
||||
client().prepareIndex("test", "type1", "2").setSource("field1", "value1_2"),
|
||||
client().prepareIndex("test", "type1", "3").setSource("field2", "value2_3"),
|
||||
client().prepareIndex("test", "type1", "4").setSource("field3", "value3_4"));
|
||||
|
||||
|
||||
assertHitCount(client().prepareSearch().setQuery(filteredQuery(matchAllQuery(), limitQuery(2))).get(), 4l); // no-op
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterExistsMissingTests() throws Exception {
|
||||
createIndex("test");
|
||||
@ -796,7 +781,7 @@ public class SearchQueryIT extends ESIntegTestCase {
|
||||
client().prepareIndex("test", "type1", "4").setSource(jsonBuilder().startObject().startObject("obj2").field("obj2_val", "1").endObject().field("y2", "y_2").field("field3", "value3_4").endObject()) );
|
||||
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch().setQuery(filteredQuery(matchAllQuery(), existsQuery("field1"))).get();
|
||||
SearchResponse searchResponse = client().prepareSearch().setQuery(existsQuery("field1")).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "1", "2");
|
||||
|
||||
@ -808,29 +793,29 @@ public class SearchQueryIT extends ESIntegTestCase {
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "1", "2");
|
||||
|
||||
searchResponse = client().prepareSearch().setQuery(filteredQuery(matchAllQuery(), existsQuery("field2"))).get();
|
||||
searchResponse = client().prepareSearch().setQuery(existsQuery("field2")).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "1", "3");
|
||||
|
||||
searchResponse = client().prepareSearch().setQuery(filteredQuery(matchAllQuery(), existsQuery("field3"))).get();
|
||||
searchResponse = client().prepareSearch().setQuery(existsQuery("field3")).get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("4"));
|
||||
|
||||
// wildcard check
|
||||
searchResponse = client().prepareSearch().setQuery(filteredQuery(matchAllQuery(), existsQuery("x*"))).get();
|
||||
searchResponse = client().prepareSearch().setQuery(existsQuery("x*")).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "1", "2");
|
||||
|
||||
// object check
|
||||
searchResponse = client().prepareSearch().setQuery(filteredQuery(matchAllQuery(), existsQuery("obj1"))).get();
|
||||
searchResponse = client().prepareSearch().setQuery(existsQuery("obj1")).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "1", "2");
|
||||
|
||||
searchResponse = client().prepareSearch().setQuery(filteredQuery(matchAllQuery(), missingQuery("field1"))).get();
|
||||
searchResponse = client().prepareSearch().setQuery(missingQuery("field1")).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "3", "4");
|
||||
|
||||
searchResponse = client().prepareSearch().setQuery(filteredQuery(matchAllQuery(), missingQuery("field1"))).get();
|
||||
searchResponse = client().prepareSearch().setQuery(missingQuery("field1")).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "3", "4");
|
||||
|
||||
@ -843,12 +828,12 @@ public class SearchQueryIT extends ESIntegTestCase {
|
||||
assertSearchHits(searchResponse, "3", "4");
|
||||
|
||||
// wildcard check
|
||||
searchResponse = client().prepareSearch().setQuery(filteredQuery(matchAllQuery(), missingQuery("x*"))).get();
|
||||
searchResponse = client().prepareSearch().setQuery(missingQuery("x*")).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "3", "4");
|
||||
|
||||
// object check
|
||||
searchResponse = client().prepareSearch().setQuery(filteredQuery(matchAllQuery(), missingQuery("obj1"))).get();
|
||||
searchResponse = client().prepareSearch().setQuery(missingQuery("obj1")).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "3", "4");
|
||||
}
|
||||
@ -1157,10 +1142,10 @@ public class SearchQueryIT extends ESIntegTestCase {
|
||||
client().prepareIndex("test", "type", "4").setSource("term", "4") );
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("term", new String[0]))).get();
|
||||
.setQuery(constantScoreQuery(termsQuery("term", new String[0]))).get();
|
||||
assertHitCount(searchResponse, 0l);
|
||||
|
||||
searchResponse = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), idsQuery())).get();
|
||||
searchResponse = client().prepareSearch("test").setQuery(idsQuery()).get();
|
||||
assertHitCount(searchResponse, 0l);
|
||||
}
|
||||
|
||||
@ -1175,60 +1160,60 @@ public class SearchQueryIT extends ESIntegTestCase {
|
||||
client().prepareIndex("test", "type", "4").setSource("str", "4", "lng", 4l, "dbl", 4.0d));
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("str", "1", "4"))).get();
|
||||
.setQuery(constantScoreQuery(termsQuery("str", "1", "4"))).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "1", "4");
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("lng", new long[] {2, 3}))).get();
|
||||
.setQuery(constantScoreQuery(termsQuery("lng", new long[] {2, 3}))).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "2", "3");
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("dbl", new double[]{2, 3}))).get();
|
||||
.setQuery(constantScoreQuery(termsQuery("dbl", new double[]{2, 3}))).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "2", "3");
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("lng", new int[] {1, 3}))).get();
|
||||
.setQuery(constantScoreQuery(termsQuery("lng", new int[] {1, 3}))).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "1", "3");
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("dbl", new float[] {2, 4}))).get();
|
||||
.setQuery(constantScoreQuery(termsQuery("dbl", new float[] {2, 4}))).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "2", "4");
|
||||
|
||||
// test partial matching
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("str", "2", "5"))).get();
|
||||
.setQuery(constantScoreQuery(termsQuery("str", "2", "5"))).get();
|
||||
assertNoFailures(searchResponse);
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("2"));
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("dbl", new double[] {2, 5}))).get();
|
||||
.setQuery(constantScoreQuery(termsQuery("dbl", new double[] {2, 5}))).get();
|
||||
assertNoFailures(searchResponse);
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("2"));
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("lng", new long[] {2, 5}))).get();
|
||||
.setQuery(constantScoreQuery(termsQuery("lng", new long[] {2, 5}))).get();
|
||||
assertNoFailures(searchResponse);
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("2"));
|
||||
|
||||
// test valid type, but no matching terms
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("str", "5", "6"))).get();
|
||||
.setQuery(constantScoreQuery(termsQuery("str", "5", "6"))).get();
|
||||
assertHitCount(searchResponse, 0l);
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("dbl", new double[] {5, 6}))).get();
|
||||
.setQuery(constantScoreQuery(termsQuery("dbl", new double[] {5, 6}))).get();
|
||||
assertHitCount(searchResponse, 0l);
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("lng", new long[] {5, 6}))).get();
|
||||
.setQuery(constantScoreQuery(termsQuery("lng", new long[] {5, 6}))).get();
|
||||
assertHitCount(searchResponse, 0l);
|
||||
}
|
||||
|
||||
@ -1269,62 +1254,62 @@ public class SearchQueryIT extends ESIntegTestCase {
|
||||
client().prepareIndex("test", "type", "4").setSource("term", "4") );
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsLookupQuery("term").lookupIndex("lookup").lookupType("type").lookupId("1").lookupPath("terms"))
|
||||
.setQuery(termsLookupQuery("term").lookupIndex("lookup").lookupType("type").lookupId("1").lookupPath("terms")
|
||||
).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "1", "3");
|
||||
|
||||
// same as above, just on the _id...
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsLookupQuery("_id").lookupIndex("lookup").lookupType("type").lookupId("1").lookupPath("terms"))
|
||||
.setQuery(termsLookupQuery("_id").lookupIndex("lookup").lookupType("type").lookupId("1").lookupPath("terms")
|
||||
).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "1", "3");
|
||||
|
||||
// another search with same parameters...
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsLookupQuery("term").lookupIndex("lookup").lookupType("type").lookupId("1").lookupPath("terms"))
|
||||
.setQuery(termsLookupQuery("term").lookupIndex("lookup").lookupType("type").lookupId("1").lookupPath("terms")
|
||||
).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "1", "3");
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsLookupQuery("term").lookupIndex("lookup").lookupType("type").lookupId("2").lookupPath("terms"))
|
||||
.setQuery(termsLookupQuery("term").lookupIndex("lookup").lookupType("type").lookupId("2").lookupPath("terms")
|
||||
).get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("2"));
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsLookupQuery("term").lookupIndex("lookup").lookupType("type").lookupId("3").lookupPath("terms"))
|
||||
.setQuery(termsLookupQuery("term").lookupIndex("lookup").lookupType("type").lookupId("3").lookupPath("terms")
|
||||
).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "2", "4");
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsLookupQuery("term").lookupIndex("lookup").lookupType("type").lookupId("4").lookupPath("terms"))
|
||||
.setQuery(termsLookupQuery("term").lookupIndex("lookup").lookupType("type").lookupId("4").lookupPath("terms")
|
||||
).get();
|
||||
assertHitCount(searchResponse, 0l);
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsLookupQuery("term").lookupIndex("lookup2").lookupType("type").lookupId("1").lookupPath("arr.term"))
|
||||
.setQuery(termsLookupQuery("term").lookupIndex("lookup2").lookupType("type").lookupId("1").lookupPath("arr.term")
|
||||
).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "1", "3");
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsLookupQuery("term").lookupIndex("lookup2").lookupType("type").lookupId("2").lookupPath("arr.term"))
|
||||
.setQuery(termsLookupQuery("term").lookupIndex("lookup2").lookupType("type").lookupId("2").lookupPath("arr.term")
|
||||
).get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("2"));
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsLookupQuery("term").lookupIndex("lookup2").lookupType("type").lookupId("3").lookupPath("arr.term"))
|
||||
.setQuery(termsLookupQuery("term").lookupIndex("lookup2").lookupType("type").lookupId("3").lookupPath("arr.term")
|
||||
).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
assertSearchHits(searchResponse, "2", "4");
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(filteredQuery(matchAllQuery(), termsLookupQuery("not_exists").lookupIndex("lookup2").lookupType("type").lookupId("3").lookupPath("arr.term"))
|
||||
.setQuery(termsLookupQuery("not_exists").lookupIndex("lookup2").lookupType("type").lookupId("3").lookupPath("arr.term")
|
||||
).get();
|
||||
assertHitCount(searchResponse, 0l);
|
||||
}
|
||||
@ -1473,42 +1458,42 @@ public class SearchQueryIT extends ESIntegTestCase {
|
||||
assertFirstHit(searchResponse, hasId("1"));
|
||||
|
||||
logger.info("--> term filter on 1");
|
||||
searchResponse = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termQuery("num_byte", 1))).get();
|
||||
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termQuery("num_byte", 1))).get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("1"));
|
||||
searchResponse = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termQuery("num_short", 1))).get();
|
||||
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termQuery("num_short", 1))).get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("1"));
|
||||
searchResponse = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termQuery("num_integer", 1))).get();
|
||||
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termQuery("num_integer", 1))).get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("1"));
|
||||
searchResponse = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termQuery("num_long", 1))).get();
|
||||
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termQuery("num_long", 1))).get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("1"));
|
||||
searchResponse = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termQuery("num_float", 1))).get();
|
||||
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termQuery("num_float", 1))).get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("1"));
|
||||
searchResponse = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termQuery("num_double", 1))).get();
|
||||
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termQuery("num_double", 1))).get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("1"));
|
||||
|
||||
logger.info("--> terms filter on 1");
|
||||
searchResponse = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termsQuery("num_byte", new int[]{1}))).get();
|
||||
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsQuery("num_byte", new int[]{1}))).get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("1"));
|
||||
searchResponse = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termsQuery("num_short", new int[]{1}))).get();
|
||||
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsQuery("num_short", new int[]{1}))).get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("1"));
|
||||
searchResponse = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termsQuery("num_integer", new int[]{1}))).get();
|
||||
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsQuery("num_integer", new int[]{1}))).get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("1"));
|
||||
searchResponse = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termsQuery("num_long", new int[]{1}))).get();
|
||||
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsQuery("num_long", new int[]{1}))).get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("1"));
|
||||
searchResponse = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termsQuery("num_float", new int[]{1}))).get();
|
||||
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsQuery("num_float", new int[]{1}))).get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("1"));
|
||||
searchResponse = client().prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termsQuery("num_double", new int[]{1}))).get();
|
||||
searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsQuery("num_double", new int[]{1}))).get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertFirstHit(searchResponse, hasId("1"));
|
||||
}
|
||||
@ -2100,103 +2085,6 @@ functionScoreQuery(scriptFunction(new Script("_doc['score'].value")))).setMinSco
|
||||
assertHitCount(client().prepareCount("test").setQuery(rangeQuery("field").lte(-999999999999L)).get(), 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRangeFilterWithTimeZone() throws Exception {
|
||||
assertAcked(prepareCreate("test")
|
||||
.addMapping("type1", "date", "type=date", "num", "type=integer"));
|
||||
|
||||
indexRandom(true,
|
||||
client().prepareIndex("test", "type1", "1").setSource("date", "2014-01-01", "num", 1),
|
||||
client().prepareIndex("test", "type1", "2").setSource("date", "2013-12-31T23:00:00", "num", 2),
|
||||
client().prepareIndex("test", "type1", "3").setSource("date", "2014-01-01T01:00:00", "num", 3),
|
||||
// Now in UTC+1
|
||||
client().prepareIndex("test", "type1", "4").setSource("date", DateTime.now(DateTimeZone.forOffsetHours(1)).getMillis(), "num", 4));
|
||||
|
||||
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch("test")
|
||||
.setQuery(QueryBuilders.filteredQuery(matchAllQuery(), QueryBuilders.rangeQuery("date").from("2014-01-01T00:00:00").to("2014-01-01T00:59:00")))
|
||||
.get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), is("1"));
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(QueryBuilders.filteredQuery(matchAllQuery(), QueryBuilders.rangeQuery("date").from("2013-12-31T23:00:00").to("2013-12-31T23:59:00")))
|
||||
.get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), is("2"));
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(QueryBuilders.filteredQuery(matchAllQuery(), QueryBuilders.rangeQuery("date").from("2014-01-01T01:00:00").to("2014-01-01T01:59:00")))
|
||||
.get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), is("3"));
|
||||
|
||||
// We explicitly define a time zone in the from/to dates so whatever the time zone is, it won't be used
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(QueryBuilders.filteredQuery(matchAllQuery(), QueryBuilders.rangeQuery("date").from("2014-01-01T00:00:00Z").to("2014-01-01T00:59:00Z").timeZone("+10:00")))
|
||||
.get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), is("1"));
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(QueryBuilders.filteredQuery(matchAllQuery(), QueryBuilders.rangeQuery("date").from("2013-12-31T23:00:00Z").to("2013-12-31T23:59:00Z").timeZone("+10:00")))
|
||||
.get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), is("2"));
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(QueryBuilders.filteredQuery(matchAllQuery(), QueryBuilders.rangeQuery("date").from("2014-01-01T01:00:00Z").to("2014-01-01T01:59:00Z").timeZone("+10:00")))
|
||||
.get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), is("3"));
|
||||
|
||||
// We define a time zone to be applied to the filter and from/to have no time zone
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(QueryBuilders.filteredQuery(matchAllQuery(), QueryBuilders.rangeQuery("date").from("2014-01-01T03:00:00").to("2014-01-01T03:59:00").timeZone("+03:00")))
|
||||
.get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), is("1"));
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(QueryBuilders.filteredQuery(matchAllQuery(), QueryBuilders.rangeQuery("date").from("2014-01-01T02:00:00").to("2014-01-01T02:59:00").timeZone("+03:00")))
|
||||
.get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), is("2"));
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(QueryBuilders.filteredQuery(matchAllQuery(), QueryBuilders.rangeQuery("date").from("2014-01-01T04:00:00").to("2014-01-01T04:59:00").timeZone("+03:00")))
|
||||
.get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), is("3"));
|
||||
|
||||
// When we use long values, it means we have ms since epoch UTC based so we don't apply any transformation
|
||||
try {
|
||||
client().prepareSearch("test")
|
||||
.setQuery(QueryBuilders.filteredQuery(matchAllQuery(), QueryBuilders.rangeQuery("date").from(1388534400000L).to(1388537940999L).timeZone("+01:00")))
|
||||
.get();
|
||||
fail("A Range Filter using ms since epoch with a TimeZone should raise a QueryParsingException");
|
||||
} catch (SearchPhaseExecutionException e) {
|
||||
// We expect it
|
||||
}
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(QueryBuilders.filteredQuery(matchAllQuery(), QueryBuilders.rangeQuery("date").from("2014-01-01").to("2014-01-01T00:59:00").timeZone("-01:00")))
|
||||
.get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), is("3"));
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(QueryBuilders.filteredQuery(matchAllQuery(), QueryBuilders.rangeQuery("date").from("now/d-1d").timeZone("+01:00")))
|
||||
.get();
|
||||
assertHitCount(searchResponse, 1l);
|
||||
assertThat(searchResponse.getHits().getAt(0).getId(), is("4"));
|
||||
|
||||
// A Range Filter on a numeric field with a TimeZone should raise an exception
|
||||
try {
|
||||
client().prepareSearch("test")
|
||||
.setQuery(QueryBuilders.filteredQuery(matchAllQuery(), QueryBuilders.rangeQuery("num").from("0").to("4").timeZone("-01:00")))
|
||||
.get();
|
||||
fail("A Range Filter on a numeric field with a TimeZone should raise a QueryParsingException");
|
||||
} catch (SearchPhaseExecutionException e) {
|
||||
// We expect it
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRangeQueryWithTimeZone() throws Exception {
|
||||
assertAcked(prepareCreate("test")
|
||||
@ -2367,58 +2255,6 @@ functionScoreQuery(scriptFunction(new Script("_doc['score'].value")))).setMinSco
|
||||
assertSearchHits(searchResponse, "2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilteredQuery() throws Exception {
|
||||
Settings.Builder builder = Settings.settingsBuilder().put(indexSettings());
|
||||
createIndex("test");
|
||||
int numDocs = randomIntBetween(100, 150);
|
||||
IndexRequestBuilder[] docs = new IndexRequestBuilder[numDocs];
|
||||
for (int i = 0; i < numDocs; i++) {
|
||||
docs[i] = client().prepareIndex("test", "type1", String.valueOf(i)).setSource("field1", English.intToEnglish(i));
|
||||
}
|
||||
|
||||
indexRandom(true, docs);
|
||||
|
||||
int iters = between(1, 100);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
String intToEnglish = English.intToEnglish(between(0, numDocs - 1));
|
||||
String query = intToEnglish.split(" ")[0];
|
||||
String filter = intToEnglish.split(" ")[0];
|
||||
|
||||
SearchResponse one = client().prepareSearch()
|
||||
.setQuery(QueryBuilders.constantScoreQuery(QueryBuilders.filteredQuery(QueryBuilders.termQuery("field1", query),
|
||||
QueryBuilders.termQuery("field1", filter)))).setSize(numDocs).execute().actionGet();
|
||||
SearchResponse other = client().prepareSearch()
|
||||
.setQuery(QueryBuilders.constantScoreQuery(QueryBuilders.filteredQuery(QueryBuilders.termQuery("field1", filter),
|
||||
QueryBuilders.termQuery("field1", query)))).setSize(numDocs).execute().actionGet();
|
||||
|
||||
Set<String> oneIds = new HashSet<>();
|
||||
for (SearchHit hit : one.getHits().hits()) {
|
||||
oneIds.add(hit.id());
|
||||
}
|
||||
Set<String> otherIds = new HashSet<>();
|
||||
for (SearchHit hit : other.getHits().hits()) {
|
||||
otherIds.add(hit.id());
|
||||
}
|
||||
assertThat(oneIds.size(), equalTo(otherIds.size()));
|
||||
for (String id : oneIds) {
|
||||
assertThat(otherIds.contains(id), is(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test // see #7365
|
||||
public void testFilteredQueryWithoutQuery() throws Exception {
|
||||
createIndex("test");
|
||||
ensureYellow("test");
|
||||
indexRandom(true, client().prepareIndex("test", "type1", "1").setSource("field1", "value1"));
|
||||
SearchResponse response = client().prepareSearch()
|
||||
.setQuery(QueryBuilders.filteredQuery(null,
|
||||
QueryBuilders.termQuery("field1", "value1"))).get();
|
||||
assertSearchResponse(response);
|
||||
assertHitCount(response, 1l);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryStringParserCache() throws Exception {
|
||||
createIndex("test");
|
||||
|
@ -34,7 +34,6 @@ import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.filteredQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.scriptQuery;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
@ -72,7 +71,7 @@ public class ScriptQuerySearchIT extends ESIntegTestCase {
|
||||
|
||||
logger.info("running doc['num1'].value > 1");
|
||||
SearchResponse response = client().prepareSearch()
|
||||
.setQuery(filteredQuery(matchAllQuery(), scriptQuery(new Script("doc['num1'].value > 1")))).addSort("num1", SortOrder.ASC)
|
||||
.setQuery(scriptQuery(new Script("doc['num1'].value > 1"))).addSort("num1", SortOrder.ASC)
|
||||
.addScriptField("sNum1", new Script("doc['num1'].value")).execute().actionGet();
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(2l));
|
||||
@ -100,8 +99,7 @@ public class ScriptQuerySearchIT extends ESIntegTestCase {
|
||||
response = client()
|
||||
.prepareSearch()
|
||||
.setQuery(
|
||||
filteredQuery(matchAllQuery(),
|
||||
scriptQuery(new Script("doc['num1'].value > param1", ScriptType.INLINE, null, params))))
|
||||
scriptQuery(new Script("doc['num1'].value > param1", ScriptType.INLINE, null, params)))
|
||||
.addSort("num1", SortOrder.ASC).addScriptField("sNum1", new Script("doc['num1'].value")).execute().actionGet();
|
||||
|
||||
assertThat(response.getHits().totalHits(), equalTo(3l));
|
||||
|
@ -156,18 +156,18 @@ public class SimpleSortIT extends ESIntegTestCase {
|
||||
int docs = builders.size();
|
||||
indexRandom(true, builders);
|
||||
ensureYellow();
|
||||
SearchResponse allDocsResponse = client().prepareSearch().setQuery(QueryBuilders.filteredQuery(matchAllQuery(),
|
||||
SearchResponse allDocsResponse = client().prepareSearch().setQuery(
|
||||
QueryBuilders.boolQuery().must(QueryBuilders.termQuery("foo", "bar")).must(
|
||||
QueryBuilders.rangeQuery("timeUpdated").gte("2014/0" + randomIntBetween(1, 7) + "/01"))))
|
||||
QueryBuilders.rangeQuery("timeUpdated").gte("2014/0" + randomIntBetween(1, 7) + "/01")))
|
||||
.addSort(new FieldSortBuilder("timeUpdated").order(SortOrder.ASC).unmappedType("date"))
|
||||
.setSize(docs).get();
|
||||
assertSearchResponse(allDocsResponse);
|
||||
|
||||
final int numiters = randomIntBetween(1, 20);
|
||||
for (int i = 0; i < numiters; i++) {
|
||||
SearchResponse searchResponse = client().prepareSearch().setQuery(QueryBuilders.filteredQuery(matchAllQuery(),
|
||||
SearchResponse searchResponse = client().prepareSearch().setQuery(
|
||||
QueryBuilders.boolQuery().must(QueryBuilders.termQuery("foo", "bar")).must(
|
||||
QueryBuilders.rangeQuery("timeUpdated").gte("2014/" + String.format(Locale.ROOT, "%02d", randomIntBetween(1, 7)) + "/01"))))
|
||||
QueryBuilders.rangeQuery("timeUpdated").gte("2014/" + String.format(Locale.ROOT, "%02d", randomIntBetween(1, 7)) + "/01")))
|
||||
.addSort(new FieldSortBuilder("timeUpdated").order(SortOrder.ASC).unmappedType("date"))
|
||||
.setSize(scaledRandomIntBetween(1, docs)).get();
|
||||
assertSearchResponse(searchResponse);
|
||||
|
@ -1180,12 +1180,10 @@ public class SuggestSearchIT extends ESIntegTestCase {
|
||||
// suggest with collation
|
||||
String filterStringAsFilter = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("query")
|
||||
.startObject("match_phrase")
|
||||
.field("title", "{{suggestion}}")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.string();
|
||||
|
||||
PhraseSuggestionBuilder filteredFilterSuggest = suggest.collateQuery(filterStringAsFilter);
|
||||
|
@ -25,7 +25,6 @@ import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.index.query.QueryBuilders.filteredQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.scriptQuery;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
@ -46,7 +45,7 @@ public class SearchTimeoutIT extends ESIntegTestCase {
|
||||
|
||||
SearchResponse searchResponse = client().prepareSearch("test")
|
||||
.setTimeout("10ms")
|
||||
.setQuery(filteredQuery(matchAllQuery(), scriptQuery(new Script("Thread.sleep(500); return true;"))))
|
||||
.setQuery(scriptQuery(new Script("Thread.sleep(500); return true;")))
|
||||
.execute().actionGet();
|
||||
assertThat(searchResponse.isTimedOut(), equalTo(true));
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ public class ContextAndHeaderTransportIT extends ESIntegTestCase {
|
||||
.preparePutIndexedScript(
|
||||
MustacheScriptEngineService.NAME,
|
||||
"my_script",
|
||||
jsonBuilder().startObject().field("script", "{ \"query\": { \"match\": { \"name\": \"Star Wars\" }}}").endObject()
|
||||
jsonBuilder().startObject().field("script", "{ \"match\": { \"name\": \"Star Wars\" }}").endObject()
|
||||
.string()).get();
|
||||
assertThat(scriptResponse.isCreated(), is(true));
|
||||
|
||||
@ -414,12 +414,10 @@ public class ContextAndHeaderTransportIT extends ESIntegTestCase {
|
||||
|
||||
String filterStringAsFilter = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("query")
|
||||
.startObject("match_phrase")
|
||||
.field("title", "{{suggestion}}")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.string();
|
||||
|
||||
PutIndexedScriptResponse scriptResponse = transportClient()
|
||||
|
@ -1,21 +0,0 @@
|
||||
{
|
||||
"filtered":{
|
||||
"filter":{
|
||||
"and":{
|
||||
"filters":[
|
||||
{
|
||||
"term":{
|
||||
"name.first":"shay1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"term":{
|
||||
"name.first":"shay4"
|
||||
}
|
||||
}
|
||||
],
|
||||
"_cache" : true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
"filter":{
|
||||
"and":{
|
||||
"filters":[
|
||||
{
|
||||
"term":{
|
||||
"name.first":"shay1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"term":{
|
||||
"name.first":"shay4"
|
||||
}
|
||||
}
|
||||
],
|
||||
"_name":"test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
"filter":{
|
||||
"and":{
|
||||
"filters":[
|
||||
{
|
||||
"term":{
|
||||
"name.first":"shay1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"term":{
|
||||
"name.first":"shay4"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
"filter":{
|
||||
"and":[
|
||||
{
|
||||
"term":{
|
||||
"name.first":"shay1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"term":{
|
||||
"name.first":"shay4"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
{
|
||||
"filtered": {
|
||||
"filter": {
|
||||
"nested": {
|
||||
"path": "nested",
|
||||
"query": {
|
||||
"bool": {
|
||||
"must": [],
|
||||
"must_not": [],
|
||||
"should": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"query": []
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
filtered:{
|
||||
query:{
|
||||
term:{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
filter:{
|
||||
term:{
|
||||
"name.last":"banon"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
filtered:{
|
||||
filter:{
|
||||
term:{
|
||||
"name.last":"banon"
|
||||
}
|
||||
},
|
||||
query:{
|
||||
term:{
|
||||
"name.first":"shay"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
{
|
||||
filtered:{
|
||||
filter:{
|
||||
range:{
|
||||
age:{
|
||||
from:"23",
|
||||
to:"54",
|
||||
include_lower:true,
|
||||
include_upper:false
|
||||
}
|
||||
}
|
||||
},
|
||||
query:{
|
||||
term:{
|
||||
"name.first":"shay"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
{
|
||||
filtered:{
|
||||
query:{
|
||||
wildcard:{
|
||||
"name.first":{
|
||||
wildcard:"sh*",
|
||||
boost:1.1
|
||||
}
|
||||
}
|
||||
},
|
||||
filter:{
|
||||
term:{
|
||||
"name.last":"banon"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
"filter":{
|
||||
"fquery":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.last":"banon"
|
||||
}
|
||||
},
|
||||
"_name":"test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
{
|
||||
"fquery": {
|
||||
"query": {
|
||||
"filtered": {
|
||||
"query": {
|
||||
"term": {
|
||||
"text": "apache"
|
||||
}
|
||||
},
|
||||
"filter": {
|
||||
"term": {
|
||||
"text": "apache"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered" : {
|
||||
"query" : {
|
||||
"match_all" : {}
|
||||
},
|
||||
"filter" : {
|
||||
"geo_shape" : {
|
||||
"country" : {
|
||||
"shape" : {
|
||||
@ -16,6 +11,4 @@
|
||||
"relation" : "intersects"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_bounding_box":{
|
||||
"location":{
|
||||
"top_left":[-70, 40],
|
||||
@ -11,6 +6,4 @@
|
||||
},
|
||||
"_name":"test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,8 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_bounding_box":{
|
||||
"location":{
|
||||
"top_left":[-70, 40],
|
||||
"bottom_right":[-80, 30]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_bounding_box":{
|
||||
"location":{
|
||||
"top_left":{
|
||||
@ -16,6 +11,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,8 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_bounding_box":{
|
||||
"location":{
|
||||
"top_left":"40, -70",
|
||||
"bottom_right":"30, -80"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,8 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_bounding_box":{
|
||||
"location":{
|
||||
"top_left":"drn5x1g8cu2y",
|
||||
"bottom_right":"30, -80"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,8 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_bounding_box":{
|
||||
"location":{
|
||||
"top_right":"40, -80",
|
||||
"bottom_left":"30, -70"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_bounding_box":{
|
||||
"location":{
|
||||
"right": -80,
|
||||
@ -12,6 +7,4 @@
|
||||
"bottom": 30
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_distance":{
|
||||
"distance":"12mi",
|
||||
"location":{
|
||||
@ -12,6 +7,4 @@
|
||||
},
|
||||
"_name":"test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_distance":{
|
||||
"distance":"12mi",
|
||||
"location":{
|
||||
@ -11,6 +6,4 @@
|
||||
"lon":-70
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_distance":{
|
||||
"distance":19.312128,
|
||||
"unit":"km",
|
||||
@ -12,6 +7,4 @@
|
||||
"lon":-70
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_distance":{
|
||||
"distance":"19.312128km",
|
||||
"location":{
|
||||
@ -11,6 +6,4 @@
|
||||
"lon":-70
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_distance":{
|
||||
"distance":"12mi",
|
||||
"unit":"km",
|
||||
@ -12,6 +7,4 @@
|
||||
"lon":-70
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,6 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_distance":{
|
||||
"distance":"12mi",
|
||||
"location":[-70, 40]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,6 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_distance":{
|
||||
"distance":"12mi",
|
||||
"location":"40, -70"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,6 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_distance":{
|
||||
"distance":"12mi",
|
||||
"location":"drn5x1g8cu2y"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_distance":{
|
||||
"distance":12,
|
||||
"unit":"mi",
|
||||
@ -12,6 +7,4 @@
|
||||
"lon":-70
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_distance":{
|
||||
"distance":"12",
|
||||
"unit":"mi",
|
||||
@ -12,6 +7,4 @@
|
||||
"lon":-70
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_distance":{
|
||||
"distance":"19.312128",
|
||||
"location":{
|
||||
@ -11,6 +6,4 @@
|
||||
"lon":-70
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_distance":{
|
||||
"distance":19.312128,
|
||||
"location":{
|
||||
@ -11,6 +6,4 @@
|
||||
"lon":-70
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_distance":{
|
||||
"distance":"19.312128",
|
||||
"unit":"km",
|
||||
@ -12,6 +7,4 @@
|
||||
"lon":-70
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_polygon":{
|
||||
"location":{
|
||||
"points":[
|
||||
@ -14,6 +9,4 @@
|
||||
},
|
||||
"_name":"test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_polygon":{
|
||||
"location":{
|
||||
"points":[
|
||||
@ -13,6 +8,4 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_polygon":{
|
||||
"location":{
|
||||
"points":[
|
||||
@ -22,6 +17,4 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_polygon":{
|
||||
"location":{
|
||||
"points":[
|
||||
@ -13,6 +8,4 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,4 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"match_all":{}
|
||||
},
|
||||
"filter":{
|
||||
"geo_polygon":{
|
||||
"location":{
|
||||
"points":[
|
||||
@ -13,6 +8,4 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,9 @@
|
||||
{
|
||||
"filtered":{
|
||||
"not":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
"filter":{
|
||||
"not":{
|
||||
"filter":{
|
||||
"term":{
|
||||
"name.first":"shay1"
|
||||
}
|
||||
}
|
||||
"name.first":"shay1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,7 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
"filter":{
|
||||
"not":{
|
||||
"term":{
|
||||
"name.first":"shay1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,7 @@
|
||||
{
|
||||
"filtered":{
|
||||
"filter":{
|
||||
"not":{
|
||||
"term":{
|
||||
"name.first":"shay1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first":"shay"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +0,0 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
"filter":{
|
||||
"or":{
|
||||
"filters":[
|
||||
{
|
||||
"term":{
|
||||
"name.first":"shay1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"term":{
|
||||
"name.first":"shay4"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
"filter":{
|
||||
"or":[
|
||||
{
|
||||
"term":{
|
||||
"name.first":"shay1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"term":{
|
||||
"name.first":"shay4"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
"filter":{
|
||||
"prefix":{
|
||||
"name.first":"sh",
|
||||
"_name":"test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
"filter":{
|
||||
"prefix":{
|
||||
"name.first":"sh"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,5 @@
|
||||
{
|
||||
filtered:{
|
||||
query:{
|
||||
term:{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
filter:{
|
||||
query:{
|
||||
term:{
|
||||
"name.last":"banon"
|
||||
}
|
||||
}
|
||||
}
|
||||
term:{
|
||||
"name.first":"shay"
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
"filter":{
|
||||
"range":{
|
||||
"age":{
|
||||
"from":"23",
|
||||
"to":"54",
|
||||
"include_lower":true,
|
||||
"include_upper":false
|
||||
},
|
||||
"_name":"test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
{
|
||||
filtered:{
|
||||
query:{
|
||||
term:{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
filter:{
|
||||
range:{
|
||||
age:{
|
||||
from:"23",
|
||||
to:"54",
|
||||
include_lower:true,
|
||||
include_upper:false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
{
|
||||
"filtered": {
|
||||
"query": {
|
||||
"term": {
|
||||
"name.first": "shay"
|
||||
}
|
||||
},
|
||||
"filter": {
|
||||
"regexp":{
|
||||
"name.first" : {
|
||||
"value" : "s.*y",
|
||||
"flags" : "INTERSECTION|COMPLEMENT|EMPTY"
|
||||
},
|
||||
"_name":"test",
|
||||
"_cache" : true,
|
||||
"_cache_key" : "key"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
{
|
||||
"filtered": {
|
||||
"query": {
|
||||
"term": {
|
||||
"name.first": "shay"
|
||||
}
|
||||
},
|
||||
"filter": {
|
||||
"regexp":{
|
||||
"name.first" : {
|
||||
"value" : "s.*y",
|
||||
"flags" : "INTERSECTION|COMPLEMENT|EMPTY"
|
||||
},
|
||||
"_name":"test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
{
|
||||
"filtered": {
|
||||
"query": {
|
||||
"term": {
|
||||
"name.first": "shay"
|
||||
}
|
||||
},
|
||||
"filter": {
|
||||
"regexp": {
|
||||
"name.first": {
|
||||
"value": "s.*y",
|
||||
"max_determinized_states": 6000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
{
|
||||
"filtered": {
|
||||
"query": {
|
||||
"term": {
|
||||
"name.first": "shay"
|
||||
}
|
||||
},
|
||||
"filter": {
|
||||
"regexp":{
|
||||
"name.first" : "s.*y",
|
||||
"_name" : "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"filtered": {
|
||||
"query": {
|
||||
"term": {
|
||||
"name.first": "shay"
|
||||
}
|
||||
},
|
||||
"filter": {
|
||||
"regexp":{
|
||||
"name.first" : "s.*y"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"filtered": {
|
||||
"filter": {
|
||||
"term": {
|
||||
"name.first": { "value": "shay" },
|
||||
"name.last": { "value": "banon" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first": "shay",
|
||||
"name.last" : "banon"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
"filter":{
|
||||
"term":{
|
||||
"name.last":"banon",
|
||||
"_name":"test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
"filter":{
|
||||
"term":{
|
||||
"name.last":"banon"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,10 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
"filter":{
|
||||
"constant_score": {
|
||||
"filter": {
|
||||
"terms":{
|
||||
"name.last":["banon", "kimchy"],
|
||||
"_name":"test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,9 @@
|
||||
{
|
||||
"filtered":{
|
||||
"query":{
|
||||
"term":{
|
||||
"name.first":"shay"
|
||||
}
|
||||
},
|
||||
"filter":{
|
||||
"constant_score": {
|
||||
"filter": {
|
||||
"terms":{
|
||||
"name.last":["banon", "kimchy"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
{
|
||||
"aggs": {
|
||||
"issue7240": {
|
||||
"aggs": {
|
||||
"terms": {
|
||||
"terms": {
|
||||
"field": "field"
|
||||
}
|
||||
}
|
||||
},
|
||||
"filter": {
|
||||
"fquery": {
|
||||
"query": {
|
||||
"filtered": {
|
||||
"query": {
|
||||
"bool": {}
|
||||
},
|
||||
"filter": {
|
||||
"fquery": {
|
||||
"query": {
|
||||
"query_string": {
|
||||
"query": "_type:apache"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
{
|
||||
"query": {
|
||||
"filtered": {
|
||||
"filter": {
|
||||
"has_parent": {
|
||||
"type": "foo",
|
||||
"query": {
|
||||
"bool": {
|
||||
"must": [],
|
||||
"must_not": [],
|
||||
"should": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"query": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user