SearchResponse hits vs facet counts

Hi,

Is there a reason why I cannot use the SearchResponse.hits().totalHits() number instead of having a facet in the same query that returns the same number?

For example, do I need the facet in the query below or can I not just use the totalHits() count instead as both return the same number?

{"query": {
"filtered" : {
"filter" : {
"term" : { "myField" : "myValue" }
},
"query" : { "match_all" : {} }
}
},
"facets" : {
"my_facet" : {
"filter" : {
"term" : { "myField" : "myValue" }
}
}
},
"from":0,
"size":20
}'

Kind Regards,

Dirk

If you need only to know the number total of hits, don't use facets.
SearchResponse.hits().totalHits() will do it.

David.

Le 5 septembre 2012 à 16:06, Dirk dirk.deejay@gmail.com a écrit :

Hi,

Is there a reason why I cannot use the SearchResponse.hits().totalHits()
number instead of having a facet in the same query that returns the same
number?

For example, do I need the facet in the query below or can I not just use
the totalHits() count instead as both return the same number?

{"query": {
"filtered" : {
"filter" : {
"term" : { "myField" : "myValue" }
},
"query" : { "match_all" : {} }
}
},
"facets" : {
"my_facet" : {
"filter" : {
"term" : { "myField" : "myValue" }
}
}
},
"from":0,
"size":20
}'

Kind Regards,

Dirk

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/SearchResponse-hits-vs-facet-counts-tp4022436.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--