Failure to execute search request with empty top level filter
closes #3477
This commit is contained in:
parent
be103c188b
commit
5c7d7fb399
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.index.query;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.util.CloseableThreadLocal;
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
|
@ -261,7 +262,11 @@ public class IndexQueryParserService extends AbstractIndexComponent {
|
|||
public ParsedFilter parseInnerFilter(XContentParser parser) throws IOException {
|
||||
QueryParseContext context = cache.get();
|
||||
context.reset(parser);
|
||||
return new ParsedFilter(context.parseInnerFilter(), context.copyNamedFilters());
|
||||
Filter filter = context.parseInnerFilter();
|
||||
if (filter == null) {
|
||||
return null;
|
||||
}
|
||||
return new ParsedFilter(filter, context.copyNamedFilters());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -1231,6 +1231,13 @@ public class SimpleQueryTests extends AbstractSharedClusterTest {
|
|||
assertThat(response.getHits().totalHits(), equalTo(2l));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyTopLevelFilter() {
|
||||
client().prepareIndex("test", "type", "1").setSource("field", "value").setRefresh(true).execute().actionGet();
|
||||
SearchResponse searchResponse = client().prepareSearch().setFilter("{}").execute().actionGet();
|
||||
assertNoFailures(searchResponse);
|
||||
}
|
||||
|
||||
@Test // see #2926
|
||||
public void testMustNot() throws ElasticSearchException, IOException {
|
||||
client().admin().indices().prepareDelete().execute().actionGet();
|
||||
|
|
Loading…
Reference in New Issue