I have an application where I need both search results and facet 
information. Everytime a query is framed based on some filter condition and 
query words and it is passed to both facet and search request as given 
below. The field (test_field) on which the facet to be applied is present 
in all documents. 
 
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
SearchRequestBuilder srb = client    .prepareSearch("Test");
srb.setSearchType(SearchType.DFS_QUERY_THEN_FETCH).setQuery(     
boolQueryBuilder);
and 
TermsFacetBuilder facBuilder = FacetBuilders.termsFacet("test_field");
  facBuilder.facetFilter(FilterBuilders
  .queryFilter(boolQueryBuilder));
  facBuilder.fields("test_field");
  facBuilder.global(true);               // I tried commenting this too, 
but I get the same result
  srb.addFacet(facBuilder); 
 
"hits" : {
    "total" : 117,
    "max_score" : null,
    "hits" : [ {
.... }]

  "facets" : {
    "assettype" : {
      "_type" : "terms",
      "missing" : 5,
      "total" : 119,
      "other" : 0,
      "terms" : [ {....
}]
 
But the hit count is different from the facet count. Can anyone please 
explain me why this discrepancy?
 
 
Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/b2ddb7fb-2b4f-488a-b944-0ac1d5342e39%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to