I've read the elasticsearch api docs and done a lot of googling but still
cannot find a solution. I need to only output filtered items from the
faceted term search. So posting here.
Here is some sample data:
{
id: 1e27202c54a0a600e06257c0ae341e8e
interaction_type: bitly
url:
created_at: 2013-02-08T15:18:34.000Z
epoch: 1360336714000
tags: [
userid_5114575ae4b0cb71b6654320,
username_testuser1,
microsoft
]
geo_latitude: 51.900002
geo_longitude: 8.3833
geo_city: Gütersloh
geo_country_code: DE
geo_country: Germany
geo_region_code: 07
geo_region: Nordrhein-Westfalen
}
{
id: 1e27202c2e7aac00e062d233dde576aa
interaction_type: bitly
url:
created_at: 2013-02-08T15:18:28.000Z
epoch: 1360336708000
tags: [
userid_5114575ae4b0cb71b6654321,
username_testuser2,
kinect
]
geo_latitude: 23.051201
geo_longitude: 112.459702
geo_city: Zhaoqing
geo_country_code: CN
geo_country: China
geo_region_code: 30
geo_region: Guangdong
}
I want to find the number of occurrences for a bunch of user-ids for a
range of times. I came up with a filtered and faceted query like so:
{
"query": {
"range": {
"created_at": { "from": "now-10d", "to": "now"}
}
},
"from": 0,
"size": 0,
"facets": {
"tag_facet": {
"terms": {"field": "tags"},
"facet_filter": {
"or": [
{ "term": { "tags": "userid_5114575ae4b0cb71b6654321" } },
{ "term": { "tags": "userid_5114575ae4b0cb71b6654320" } }
]
}
}
}
}
The result I get is :
facets: {
tag_facet: {
_type: terms
missing: 0
total: 1947503
other: 305
terms: [
{term: username_testuser1,count: 539453}
{term: userid_5114575ae4b0cb71b6654320,count: 539453}
{term: iphone,count: 245888}
{term: microsoft,count: 193543}
{term: userid_50f06636e4b0560131c8730c,count: 107155}
{term: kinect,count: 101051}
]
}
The result I get also includes counts for other tags like username_testuser1,
microsoft, kinect etc. I dont want those results, only the counts for x
number of user-ids using [or] filters, where I will limit x to not more
than 10.
Any guidance on how to solve this? There could be 1000s of results and I
dont want to iterate through them in the app layer to find the two items
that are needed.
Thanks!
-Ripple
--
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.
For more options, visit https://groups.google.com/groups/opt_out.