0
private ElasticsearchTemplate elasticsearchTemplate = return new ElasticsearchTemplate(NodeBuilder.nodeBuilder().local(true).node().client());

FilterBuilder[] fbs = {
    FilterBuilders.geoDistanceFilter("location").point(LAT, LON).distance(10.0, DistanceUnit.KILOMETERS).optimizeBbox("memory").ge    oDistance(GeoDistance.ARC)
};  

FilterBuilder fb = FilterBuilders.andFilter(fbs);
FilteredQueryBuilder builder = QueryBuilders.filteredQuery(QueryBuilders.termsQuery("interests", INTERESTS).minimumShouldMatch("2"), fb);
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(builder).build();
List<ESClass> results = this.elasticsearchTemplate.queryForList(searchQuery, ESClass.class);
System.out.println("Count: " + results.size());

The above code written in the Java Spring framework with elasticsearch classes, keeps returning 0 results even though that is not the case. For example, if I do the query without the termsQuery on "interests", it will return correct results for the geo distance filter. But if i do only termsQuery on "interests" (without geo distance filter), it also returns correct results that have atleast two matching interests (the results from both are exactly the same). So my question is, if I combine both of them why am i getting 0 results? And yes, I have checked it SHOULD NOT be zero.

Anon
  • 27
  • 5
  • Are you sure you want to do a term query and not a match query? http://stackoverflow.com/questions/23150670/elasticsearch-match-vs-term-query – Charlie Mar 08 '16 at 22:30
  • I also don't see support for using a term query with a filter in the docs https://www.elastic.co/guide/en/elasticsearch/guide/current/_combining_queries_with_filters.html. – Charlie Mar 08 '16 at 22:32

0 Answers0