Terms Filter Lookup: Failure when no mappings for the terms field exists (no data indexed)
closes #3216
This commit is contained in:
parent
7206c60019
commit
6fd74fa39e
|
@ -157,6 +157,12 @@ public class TermsFilterParser implements FilterParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lookupId != null) {
|
if (lookupId != null) {
|
||||||
|
// if there are no mappings, then nothing has been indexing yet against this shard, so we can return
|
||||||
|
// no match (but not cached!), since the Terms Lookup relies on the fact that there are mappings...
|
||||||
|
if (fieldMapper == null) {
|
||||||
|
return Queries.MATCH_NO_FILTER;
|
||||||
|
}
|
||||||
|
|
||||||
// external lookup, use it
|
// external lookup, use it
|
||||||
TermsLookup termsLookup = new TermsLookup(fieldMapper, lookupIndex, lookupType, lookupId, lookupPath, parseContext);
|
TermsLookup termsLookup = new TermsLookup(fieldMapper, lookupIndex, lookupType, lookupId, lookupPath, parseContext);
|
||||||
if (cacheKey == null) {
|
if (cacheKey == null) {
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.elasticsearch.index.query.MatchQueryBuilder.Type;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
import org.elasticsearch.search.facet.FacetBuilders;
|
import org.elasticsearch.search.facet.FacetBuilders;
|
||||||
import org.elasticsearch.test.integration.AbstractSharedClusterTest;
|
import org.elasticsearch.test.integration.AbstractSharedClusterTest;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -933,6 +932,12 @@ public class SimpleQueryTests extends AbstractSharedClusterTest {
|
||||||
assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l));
|
assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l));
|
||||||
assertThat(searchResponse.getHits().getHits()[0].getId(), anyOf(equalTo("2"), equalTo("4")));
|
assertThat(searchResponse.getHits().getHits()[0].getId(), anyOf(equalTo("2"), equalTo("4")));
|
||||||
assertThat(searchResponse.getHits().getHits()[1].getId(), anyOf(equalTo("2"), equalTo("4")));
|
assertThat(searchResponse.getHits().getHits()[1].getId(), anyOf(equalTo("2"), equalTo("4")));
|
||||||
|
|
||||||
|
searchResponse = client().prepareSearch("test")
|
||||||
|
.setQuery(filteredQuery(matchAllQuery(), termsLookupFilter("not_exists").lookupIndex("lookup2").lookupType("type").lookupId("3").lookupPath("arr.term"))
|
||||||
|
).execute().actionGet();
|
||||||
|
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
|
||||||
|
assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue