I am applying to two search requests a filter and a query semantically identical like so:
static FilterBuilder filter(String field1Value, String field2Value){
return FilterBuilders.boolFilter().must(FilterBuilders.termFilter("field1",field1Value)).should(FilterBuilders.termFilter("field2",field2Value));
}
static QueryBuilder query(String field1Value, String field2Value){
return QueryBuilders.boolQuery().must(QueryBuilders.termQuery("field1",field1Value)).should(QueryBuilders.termQuery("field2",field2Value));
}
client.prepareSearch(indexName).setPostFilter(filter("hello", "world")).setTypes("mytype");
client.prepareSearch(indexName).setQuery(query("hello","world")).setTypes("mytype");
However, while the search with the query returns results, the search with the filter doesn't return any result. Aren't the two suppose to behave identically and if not, why?
filteredQuerythat contains your filter.