I put a sort DESC on published_at, but size works because it returns only
10 results for example, but the facet calculate on the entire dataset...
Look :
curl -X GET
'http://localhost:9200/videos/video/_search?from=0&size=20&pretty' -d
'{"query":{"bool":{"must":[{"query_string":{"query":"*","default_operator":"AND"}}]}},"sort":[{"published_at":"desc"}],"facets":{"views_count":{"statistical":{"field":"views_count"}}},"size":20,"from":0}'
Do you see any errors?
Thanks
On Sunday, March 17, 2013 6:38:24 PM UTC+1, Karel Minařík wrote:
Ah, OK, then just add a range filter on published_at to the query (to
limit the facet computation), and use size to limit the number of results
in the facet.
Karel
On Sunday, 17. March 2013 at 18:10, Fabien Guiraud wrote:
Well quite simple (you're assuming well) :
videos:
channel_id
views_count
published_at
When I do that query, the total / sum, etc... from statistical is on all
the data set. I would like have the sum of total views for the last 100
videos not the all dataset... Do you know what I mean?
I try size but it doesn't work...
On Sunday, March 17, 2013 6:07:15 PM UTC+1, Karel Minařík wrote:
SELECT SUM(views_count) FROM videos WHERE videos.channel_id = X ORDER BY published_at DESC LIMIT Y
It all depends on how you model your data in Elasticseach, that's the
hardest part. Assuming you'd have the video
documents which have a
channel_id
field and a views_count
field, you can do a filtered
0
query with a term
1 filter on channel_id
, and a terms
facet 2
over views_count
, and that will return a count
(10, by default) of most
viewed videos. (In other scenarios, you could also use a facet_filter
to
restrict facets to a certain channel_id
, eg. when you'd like to get back
facets for multiple channels.)
Karel
--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/-lQsU4k0sNU/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, send an email to
elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.
--
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.