Counting parents in a parent child relationship


(Todd Gruben) #1

I am attempting to count profiles based on the has_child filter but I am
not getting the desired results. If I execute the query against the search
api, I get the correct list of documents, but If i execute against the
count api, I get 0.

My end goal is to count profiles which have certain attributes(like male)
and has a child document that matches a certain tag. That should be
possible correct?

Thanks for a really cool product

--


(Martijn Van Groningen) #2

Hi Todd,

Executing the has_child query (and also top_children query) on the
count api has known problems.

The workaround for this problem is the use the search api with the
search type 'count':
http://www.elasticsearch.org/guide/reference/api/search/search-type.html

In general it is recommended to use the search api with search type
count over the count api for counting hits.

Martijn

On 17 September 2012 22:58, Todd Gruben tgruben@gmail.com wrote:

I am attempting to count profiles based on the has_child filter but I am not
getting the desired results. If I execute the query against the search api,
I get the correct list of documents, but If i execute against the count api,
I get 0.

My end goal is to count profiles which have certain attributes(like male)
and has a child document that matches a certain tag. That should be
possible correct?

https://gist.github.com/3739692

Thanks for a really cool product

--

--
Met vriendelijke groet,

Martijn van Groningen

--


(system) #3