How to use facet filtering with nested documents on ElasticSearch

Hi!

I have the following mapping:

curl -XPUT 'http://localhost:9200/bookstore/user/_mapping' -d '
{
"user": {
"properties": {
"user_id": { "type": "integer" },
"gender": { "type": "string", "index" : "not_analyzed" },
"age": { "type": "integer" },
"age_bracket": { "type": "string", "index" : "not_analyzed" },
"current_city": { "type": "string", "index" : "not_analyzed" },
"relationship_status": { "type": "string", "index" : "not_analyzed" },
"books" : {
"type": "nested",
"properties" : {
"b_oid": { "type": "string", "index" : "not_analyzed" },
"b_name": { "type": "string", "index" : "not_analyzed" },
"bc_id": { "type": "integer" },
"bc_name": { "type": "string", "index" : "not_analyzed" },
"bcl_name": { "type": "string", "index" : "not_analyzed" },
"b_id": { "type": "integer" }
}
}
}
}
}'

Now, I'd like to run a query where I count the books.b_names for a certain
books.bcl_name (the books category name) and, for example, where the gender
is "Male". I'm a little bit confused of how to get this to work. My query
is the following:

curl -XGET 'http://localhost:9200/bookstore/user/_search?pretty=1' -d '{
"size": 0,
"from": 0,
"query": {
"match_all": {}
},
"facets": {
"CategoryFacet": {
"terms": {
"field": "books.b_name",
"size": 5,
"shard_size": 1000,
"order": "count"
},
"nested": "books",
"facet_filter": {
"and": [
{
"nested" : {
"path" : "books",
"query" : {
"match" : {
"books.bcl_name" : "Trivia"
}
},
"join" : false
}
},
{
"term": {
"gender": "Male"
}
}
]
}
}
}
}'

So, I'd like to facet_filter on both the nested document as well as the
parent. How can I achieve this, because apparantly it doesnt's work the way
I imagined. The result of my query is the following:

{
"took" : 320,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 500000,
"max_score" : 1.0,
"hits" : [ ]
},
"facets" : {
"CategoryFacet" : {
"_type" : "terms",
"missing" : 0,
"total" : 0,
"other" : 0,
"terms" : [ ]
}
}
}

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/59a95b77-a4d5-47dc-8095-d7124cb0d1ef%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.