Merge branch 'master' into feature/query-refactoring
Conflicts: core/src/main/java/org/elasticsearch/index/query/NotQueryParser.java core/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java
This commit is contained in:
commit
4a3faf1126
|
@ -66,10 +66,6 @@ public class NotQueryParser extends BaseQueryParser<NotQueryBuilder> {
|
||||||
// its the filter, and the name is the field
|
// its the filter, and the name is the field
|
||||||
query = parseContext.parseInnerFilterToQueryBuilder(currentFieldName);
|
query = parseContext.parseInnerFilterToQueryBuilder(currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
|
||||||
queryFound = true;
|
|
||||||
// its the filter, and the name is the field
|
|
||||||
query = parseContext.parseInnerFilterToQueryBuilder(currentFieldName);
|
|
||||||
} else if (token.isValue()) {
|
} else if (token.isValue()) {
|
||||||
if ("_name".equals(currentFieldName)) {
|
if ("_name".equals(currentFieldName)) {
|
||||||
queryName = parser.text();
|
queryName = parser.text();
|
||||||
|
|
|
@ -40,8 +40,6 @@ public class TermsQueryBuilder extends AbstractQueryBuilder<TermsQueryBuilder> {
|
||||||
|
|
||||||
private Boolean disableCoord;
|
private Boolean disableCoord;
|
||||||
|
|
||||||
private String execution;
|
|
||||||
|
|
||||||
private String lookupIndex;
|
private String lookupIndex;
|
||||||
private String lookupType;
|
private String lookupType;
|
||||||
private String lookupId;
|
private String lookupId;
|
||||||
|
@ -125,20 +123,6 @@ public class TermsQueryBuilder extends AbstractQueryBuilder<TermsQueryBuilder> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the execution mode for the terms filter. Cane be either "plain", "bool"
|
|
||||||
* "and". Defaults to "plain".
|
|
||||||
* @deprecated elasticsearch now makes better decisions on its own
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public TermsQueryBuilder execution(String execution) {
|
|
||||||
this.execution = execution;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
<<<<<<< HEAD
|
|
||||||
* Sets the index name to lookup the terms from.
|
|
||||||
=======
|
|
||||||
* Sets the minimum number of matches across the provided terms. Defaults to <tt>1</tt>.
|
* Sets the minimum number of matches across the provided terms. Defaults to <tt>1</tt>.
|
||||||
* @deprecated use [bool] query instead
|
* @deprecated use [bool] query instead
|
||||||
*/
|
*/
|
||||||
|
@ -159,8 +143,7 @@ public class TermsQueryBuilder extends AbstractQueryBuilder<TermsQueryBuilder> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the filter name for the filter that can be used when searching for matched_filters per hit.
|
* Sets the index name to lookup the terms from.
|
||||||
>>>>>>> master
|
|
||||||
*/
|
*/
|
||||||
public TermsQueryBuilder lookupIndex(String lookupIndex) {
|
public TermsQueryBuilder lookupIndex(String lookupIndex) {
|
||||||
this.lookupIndex = lookupIndex;
|
this.lookupIndex = lookupIndex;
|
||||||
|
@ -214,9 +197,6 @@ public class TermsQueryBuilder extends AbstractQueryBuilder<TermsQueryBuilder> {
|
||||||
} else {
|
} else {
|
||||||
builder.field(name, values);
|
builder.field(name, values);
|
||||||
}
|
}
|
||||||
if (execution != null) {
|
|
||||||
builder.field("execution", execution);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minimumShouldMatch != null) {
|
if (minimumShouldMatch != null) {
|
||||||
builder.field("minimum_should_match", minimumShouldMatch);
|
builder.field("minimum_should_match", minimumShouldMatch);
|
||||||
|
|
|
@ -51,11 +51,9 @@ public class TermsQueryParser extends BaseQueryParserTemp {
|
||||||
|
|
||||||
private static final ParseField MIN_SHOULD_MATCH_FIELD = new ParseField("min_match", "min_should_match").withAllDeprecated("Use [bool] query instead");
|
private static final ParseField MIN_SHOULD_MATCH_FIELD = new ParseField("min_match", "min_should_match").withAllDeprecated("Use [bool] query instead");
|
||||||
private static final ParseField DISABLE_COORD_FIELD = new ParseField("disable_coord").withAllDeprecated("Use [bool] query instead");
|
private static final ParseField DISABLE_COORD_FIELD = new ParseField("disable_coord").withAllDeprecated("Use [bool] query instead");
|
||||||
|
private static final ParseField EXECUTION_FIELD = new ParseField("execution").withAllDeprecated("execution is deprecated and has no effect");
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static final String EXECUTION_KEY = "execution";
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TermsQueryParser() {
|
public TermsQueryParser() {
|
||||||
}
|
}
|
||||||
|
@ -141,7 +139,7 @@ public class TermsQueryParser extends BaseQueryParserTemp {
|
||||||
throw new QueryParsingException(parseContext, "[terms] query lookup element requires specifying the path");
|
throw new QueryParsingException(parseContext, "[terms] query lookup element requires specifying the path");
|
||||||
}
|
}
|
||||||
} else if (token.isValue()) {
|
} else if (token.isValue()) {
|
||||||
if (EXECUTION_KEY.equals(currentFieldName)) {
|
if (parseContext.parseFieldMatcher().match(currentFieldName, EXECUTION_FIELD)) {
|
||||||
// ignore
|
// ignore
|
||||||
} else if (parseContext.parseFieldMatcher().match(currentFieldName, MIN_SHOULD_MATCH_FIELD)) {
|
} else if (parseContext.parseFieldMatcher().match(currentFieldName, MIN_SHOULD_MATCH_FIELD)) {
|
||||||
if (minShouldMatch != null) {
|
if (minShouldMatch != null) {
|
||||||
|
|
|
@ -344,7 +344,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
|
||||||
.addAlias(new Alias("templated_alias-{index}"))
|
.addAlias(new Alias("templated_alias-{index}"))
|
||||||
.addAlias(new Alias("filtered_alias").filter("{\"type\":{\"value\":\"type2\"}}"))
|
.addAlias(new Alias("filtered_alias").filter("{\"type\":{\"value\":\"type2\"}}"))
|
||||||
.addAlias(new Alias("complex_filtered_alias")
|
.addAlias(new Alias("complex_filtered_alias")
|
||||||
.filter(QueryBuilders.termsQuery("_type", "typeX", "typeY", "typeZ").execution("bool")))
|
.filter(QueryBuilders.termsQuery("_type", "typeX", "typeY", "typeZ")))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
assertAcked(prepareCreate("test_index").addMapping("type1").addMapping("type2").addMapping("typeX").addMapping("typeY").addMapping("typeZ"));
|
assertAcked(prepareCreate("test_index").addMapping("type1").addMapping("type2").addMapping("typeX").addMapping("typeY").addMapping("typeZ"));
|
||||||
|
|
|
@ -1141,7 +1141,7 @@ public class SearchQueryIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFieldDatatermsQuery() throws Exception {
|
public void testTermsQuery() throws Exception {
|
||||||
assertAcked(prepareCreate("test").addMapping("type", "str", "type=string", "lng", "type=long", "dbl", "type=double"));
|
assertAcked(prepareCreate("test").addMapping("type", "str", "type=string", "lng", "type=long", "dbl", "type=double"));
|
||||||
|
|
||||||
indexRandom(true,
|
indexRandom(true,
|
||||||
|
@ -1151,60 +1151,60 @@ public class SearchQueryIT extends ESIntegTestCase {
|
||||||
client().prepareIndex("test", "type", "4").setSource("str", "4", "lng", 4l, "dbl", 4.0d));
|
client().prepareIndex("test", "type", "4").setSource("str", "4", "lng", 4l, "dbl", 4.0d));
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch("test")
|
SearchResponse searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("str", "1", "4").execution("fielddata"))).get();
|
.setQuery(filteredQuery(matchAllQuery(), termsQuery("str", "1", "4"))).get();
|
||||||
assertHitCount(searchResponse, 2l);
|
assertHitCount(searchResponse, 2l);
|
||||||
assertSearchHits(searchResponse, "1", "4");
|
assertSearchHits(searchResponse, "1", "4");
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("test")
|
searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("lng", new long[] {2, 3}).execution("fielddata"))).get();
|
.setQuery(filteredQuery(matchAllQuery(), termsQuery("lng", new long[] {2, 3}))).get();
|
||||||
assertHitCount(searchResponse, 2l);
|
assertHitCount(searchResponse, 2l);
|
||||||
assertSearchHits(searchResponse, "2", "3");
|
assertSearchHits(searchResponse, "2", "3");
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("test")
|
searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("dbl", new double[]{2, 3}).execution("fielddata"))).get();
|
.setQuery(filteredQuery(matchAllQuery(), termsQuery("dbl", new double[]{2, 3}))).get();
|
||||||
assertHitCount(searchResponse, 2l);
|
assertHitCount(searchResponse, 2l);
|
||||||
assertSearchHits(searchResponse, "2", "3");
|
assertSearchHits(searchResponse, "2", "3");
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("test")
|
searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("lng", new int[] {1, 3}).execution("fielddata"))).get();
|
.setQuery(filteredQuery(matchAllQuery(), termsQuery("lng", new int[] {1, 3}))).get();
|
||||||
assertHitCount(searchResponse, 2l);
|
assertHitCount(searchResponse, 2l);
|
||||||
assertSearchHits(searchResponse, "1", "3");
|
assertSearchHits(searchResponse, "1", "3");
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("test")
|
searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("dbl", new float[] {2, 4}).execution("fielddata"))).get();
|
.setQuery(filteredQuery(matchAllQuery(), termsQuery("dbl", new float[] {2, 4}))).get();
|
||||||
assertHitCount(searchResponse, 2l);
|
assertHitCount(searchResponse, 2l);
|
||||||
assertSearchHits(searchResponse, "2", "4");
|
assertSearchHits(searchResponse, "2", "4");
|
||||||
|
|
||||||
// test partial matching
|
// test partial matching
|
||||||
searchResponse = client().prepareSearch("test")
|
searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("str", "2", "5").execution("fielddata"))).get();
|
.setQuery(filteredQuery(matchAllQuery(), termsQuery("str", "2", "5"))).get();
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
assertHitCount(searchResponse, 1l);
|
assertHitCount(searchResponse, 1l);
|
||||||
assertFirstHit(searchResponse, hasId("2"));
|
assertFirstHit(searchResponse, hasId("2"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("test")
|
searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("dbl", new double[] {2, 5}).execution("fielddata"))).get();
|
.setQuery(filteredQuery(matchAllQuery(), termsQuery("dbl", new double[] {2, 5}))).get();
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
assertHitCount(searchResponse, 1l);
|
assertHitCount(searchResponse, 1l);
|
||||||
assertFirstHit(searchResponse, hasId("2"));
|
assertFirstHit(searchResponse, hasId("2"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("test")
|
searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("lng", new long[] {2, 5}).execution("fielddata"))).get();
|
.setQuery(filteredQuery(matchAllQuery(), termsQuery("lng", new long[] {2, 5}))).get();
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
assertHitCount(searchResponse, 1l);
|
assertHitCount(searchResponse, 1l);
|
||||||
assertFirstHit(searchResponse, hasId("2"));
|
assertFirstHit(searchResponse, hasId("2"));
|
||||||
|
|
||||||
// test valid type, but no matching terms
|
// test valid type, but no matching terms
|
||||||
searchResponse = client().prepareSearch("test")
|
searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("str", "5", "6").execution("fielddata"))).get();
|
.setQuery(filteredQuery(matchAllQuery(), termsQuery("str", "5", "6"))).get();
|
||||||
assertHitCount(searchResponse, 0l);
|
assertHitCount(searchResponse, 0l);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("test")
|
searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("dbl", new double[] {5, 6}).execution("fielddata"))).get();
|
.setQuery(filteredQuery(matchAllQuery(), termsQuery("dbl", new double[] {5, 6}))).get();
|
||||||
assertHitCount(searchResponse, 0l);
|
assertHitCount(searchResponse, 0l);
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("test")
|
searchResponse = client().prepareSearch("test")
|
||||||
.setQuery(filteredQuery(matchAllQuery(), termsQuery("lng", new long[] {5, 6}).execution("fielddata"))).get();
|
.setQuery(filteredQuery(matchAllQuery(), termsQuery("lng", new long[] {5, 6}))).get();
|
||||||
assertHitCount(searchResponse, 0l);
|
assertHitCount(searchResponse, 0l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,3 +74,7 @@ The following deprecated methods have been removed:
|
||||||
The redundant BytesQueryBuilder has been removed in favour of the
|
The redundant BytesQueryBuilder has been removed in favour of the
|
||||||
WrapperQueryBuilder internally.
|
WrapperQueryBuilder internally.
|
||||||
|
|
||||||
|
==== TermsQueryBuilder execution removed
|
||||||
|
|
||||||
|
The `TermsQueryBuilder#execution` method has been removed as it has no effect, it is ignored by the
|
||||||
|
corresponding parser.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# Integration tests for smoke testing multi-node IT
|
# Integration tests for smoke testing multi-node IT
|
||||||
#
|
# If the local machine which is running the test is low on disk space
|
||||||
|
# We can have one unassigned shard
|
||||||
---
|
---
|
||||||
"cluster health basic test, one index":
|
"cluster health basic test, one index":
|
||||||
- do:
|
- do:
|
||||||
|
@ -12,15 +13,9 @@
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
cluster.health:
|
cluster.health:
|
||||||
wait_for_status: green
|
wait_for_status: yellow
|
||||||
|
|
||||||
- is_true: cluster_name
|
- is_true: cluster_name
|
||||||
- is_false: timed_out
|
- is_false: timed_out
|
||||||
- gte: { number_of_nodes: 2 }
|
- gte: { number_of_nodes: 2 }
|
||||||
- gte: { number_of_data_nodes: 2 }
|
- gte: { number_of_data_nodes: 2 }
|
||||||
- gt: { active_primary_shards: 0 }
|
|
||||||
- gt: { active_shards: 0 }
|
|
||||||
- gte: { relocating_shards: 0 }
|
|
||||||
- match: { initializing_shards: 0 }
|
|
||||||
- match: { unassigned_shards: 0 }
|
|
||||||
- gte: { number_of_pending_tasks: 0 }
|
|
||||||
|
|
Loading…
Reference in New Issue