Hi, I'm trying to run facet on nested objects but at the moment I'm not getting the results I'm after. In the below query you can see the main query which is suppose to count the number of users which have a nested object(buying event) between 2013-10-01 and 2013-10-10 AND also have a TV as one of the products in that event. On the facet side I'm looking to get the same result, only have it done by facet - that way I can get the counts for all products between the dates (not just TV), without running the main query for each of them (the way my system works now)
What I'm expecting to get is the same count for the main query ("total":
284070) and for the facet calculation (term": "TV","count": 535445) which is
not the case at the moment.
Does anyone know what I'm doing wrong here?
Thanks in advanced,
curl-XPOST'http: //XXXXX: 9200/sample/_search?pretty=true'-d'{
"size": 0,
"query": {
"nested": {
"query": {
"bool": {
"must": [{
"term": {
"events.products.product": "TV"
}
},
{
"range": {
"events.event_time": {
"from":
"2013-10-01",
"to":
"2013-10-10",
"include_lower": true,
"include_upper": true
}
}
}]
}
},
"path": "events"
}
},
"facets": {
"tags": {
"terms": {
"field": "product",
"size": 200
},
"nested": "events",
"facet_filter": {
"range": {
"events.event_time": {
"from": "2013-10-01",
"to": "2013-10-10",
"include_lower": true,
"include_upper": true
}
}
}
}
}
}'{
"took": 96,
"timed_out": false,
"_shards": {
"total": 20,
"successful": 20,
"failed": 0
},
"hits": {
"total": 284070,
"max_score": 4.171436,
"hits": []
},
"facets": {
"tags": {
"_type": "terms",
"missing": 0,
"total": 13036875,
"other": 1901080,
"terms": [{
"term": "TV",
"count": 535445
},
{
"term": "DISHWASHER",
"count": 375003
},
{
"term": "RADIO",
"count": 316831
},
.....
mapping:
{
"user": {
"_ttl": {
"enabled": true
},
"properties": {
"name": {
"type": "string"
},
"events": {
"type": "nested",
"properties": {
"event_time": {
"type": "Date"
},
"products": {
"properties": {
"product": {
"type":
"string",
"index":
"not_analyzed"
}
}
}
}
}
}
}
}
--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/facets-on-nested-objects-tp4046760.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.
--
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/1388308488580-4046760.post%40n3.nabble.com.
For more options, visit https://groups.google.com/groups/opt_out.
