Skip to content

Commit

Permalink
Failure to execute search request with empty top level filter
Browse files Browse the repository at this point in the history
closes #3477
  • Loading branch information
kimchy committed Aug 10, 2013
1 parent 0b98a8a commit 9b82025
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Expand Up @@ -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;
Expand Down Expand Up @@ -261,7 +262,11 @@ public ParsedQuery parse(XContentParser parser) {
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
Expand Down
Expand Up @@ -1231,6 +1231,13 @@ public void testNumericRangeFilter_2826() throws Exception {
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();
Expand Down

0 comments on commit 9b82025

Please sign in to comment.