Remove support for filter element in nested query

Replaced by query.
This commit is contained in:
javanna 2015-10-27 15:57:10 +01:00 committed by Luca Cavanna
parent 152f2697f7
commit 6076ccb7b2
3 changed files with 4 additions and 46 deletions

View File

@ -20,16 +20,15 @@
package org.elasticsearch.index.query;
import org.apache.lucene.search.join.ScoreMode;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.query.support.QueryInnerHits;
import java.io.IOException;
public class NestedQueryParser implements QueryParser<NestedQueryBuilder> {
private static final ParseField FILTER_FIELD = new ParseField("filter").withAllDeprecated("query");
private static final NestedQueryBuilder PROTOTYPE = new NestedQueryBuilder("", EmptyQueryBuilder.PROTOTYPE);
@Override
@ -54,8 +53,6 @@ public class NestedQueryParser implements QueryParser<NestedQueryBuilder> {
} else if (token == XContentParser.Token.START_OBJECT) {
if ("query".equals(currentFieldName)) {
query = parseContext.parseInnerQueryBuilder();
} else if (parseContext.parseFieldMatcher().match(currentFieldName, FILTER_FIELD)) {
query = parseContext.parseInnerQueryBuilder();
} else if ("inner_hits".equals(currentFieldName)) {
queryInnerHits = new QueryInnerHits(parser);
} else {

View File

@ -20,17 +20,11 @@
package org.elasticsearch.index.query;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.join.ScoreMode;
import org.apache.lucene.search.join.ToParentBlockJoinQuery;
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
import org.elasticsearch.common.ParseFieldMatcher;
import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.fielddata.IndexFieldDataService;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.query.support.QueryInnerHits;
@ -41,7 +35,6 @@ import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.TestSearchContext;
import java.io.IOException;
import java.util.Arrays;
import static org.hamcrest.CoreMatchers.instanceOf;
@ -131,38 +124,6 @@ public class NestedQueryBuilderTests extends AbstractQueryTestCase<NestedQueryBu
}
}
public void testParseDeprecatedFilter() throws IOException {
XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint();
builder.startObject();
builder.startObject("nested");
builder.startObject("filter");
builder.startObject("terms").array(STRING_FIELD_NAME, "a", "b").endObject();// deprecated
builder.endObject();
builder.field("path", "foo.bar");
builder.endObject();
builder.endObject();
QueryShardContext shardContext = createShardContext();
QueryParseContext context = shardContext.parseContext();
XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(builder.string());
context.reset(parser);
context.parseFieldMatcher(ParseFieldMatcher.STRICT);
try {
context.parseInnerQueryBuilder();
fail("filter is deprecated");
} catch (IllegalArgumentException ex) {
assertEquals("Deprecated field [filter] used, replaced by [query]", ex.getMessage());
}
parser = XContentFactory.xContent(XContentType.JSON).createParser(builder.string());
context.reset(parser);
NestedQueryBuilder queryBuilder = (NestedQueryBuilder) context.parseInnerQueryBuilder();
QueryBuilder query = queryBuilder.query();
assertTrue(query instanceof TermsQueryBuilder);
TermsQueryBuilder tqb = (TermsQueryBuilder) query;
assertEquals(tqb.values(), Arrays.asList("a", "b"));
}
public void testValidate() {
try {
new NestedQueryBuilder(null, EmptyQueryBuilder.PROTOTYPE);

View File

@ -45,9 +45,9 @@ And here is a sample nested query usage:
}
--------------------------------------------------
The query `path` points to the nested object path, and the `query` (or
`filter`) includes the query that will run on the nested docs matching
the direct path, and joining with the root parent docs. Note that any
The query `path` points to the nested object path, and the `query`
includes the query that will run on the nested docs matching the
direct path, and joining with the root parent docs. Note that any
fields referenced inside the query must use the complete path (fully
qualified).