Facets.total and hits.total dont match

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 elasticsearch+unsubscribe@googlegroups.com.
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.

I have indexed some records by making test_field to be 'analyzed'. If the
analyzed field causing this issue, is there any other facet type/work
around which can solve the problem?

On Tuesday, January 21, 2014 12:15:45 PM UTC+5:30, Chetana wrote:

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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/a8ed55c0-6599-4612-995d-28d3340e69f7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi,

I don't have the link right now but IIRC when you have more than 1 shard there is no certainty about facet count accuracy...
The best "workaround" is either 1 shard to get exact count or extend the number of results asked for facet to achieve better (still not exact) count.

Eric

Sent from my iPhone

On 21 Jan 2014, at 07:58, Chetana ambha.career@gmail.com wrote:

I have indexed some records by making test_field to be 'analyzed'. If the analyzed field causing this issue, is there any other facet type/work around which can solve the problem?

On Tuesday, January 21, 2014 12:15:45 PM UTC+5:30, Chetana wrote:
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/a8ed55c0-6599-4612-995d-28d3340e69f7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/E2A7D14B-CCA0-48D8-BB70-56FC0ACA3112%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.