Skip to content

Instantly share code, notes, and snippets.

@fabien7337
Last active December 23, 2015 04:39
Show Gist options
  • Save fabien7337/6581246 to your computer and use it in GitHub Desktop.
Save fabien7337/6581246 to your computer and use it in GitHub Desktop.
Example of terms stats with my data
{
:id=>"---qlK1dgRw",
:channel_id=>"UC5DRS1AfES0hVY8eBRUqlrA",
:title=>"Farcry 2 w/ Kootra Ep. 13 \"Scrapyard\"",
:description=>
"Remember to send over a like and such, it helps the cats hunting for the Jackal.....he is clever.\n\nHere I am playing through Farcry 2 in preparation for Farcry 3. I have played through this game at least 10 times on xbox, including Infamous difficulty. So this should be good.",
:views_count=>38320,
:likes_count=>944,
:dislikes_count=>4,
:comments_count=>240,
:location=>'US',
:brand_ids=>[1,5,23,78],
:created_at=>Sun, 15 Sep 2013 14:39:58 +0200,
:updated_at=>Sun, 15 Sep 2013 14:40:02 +0200,
}
curl -X GET '127.0.0.1:9200/videos/video/_search?size=10&pretty' -d '{
"query":{
"match_all" : { }
},
"sort":[
{
"views_count":"desc"
}
],
"facets":{
"views_count":{
"statistical":{
"field":"views_count"
}
},
"comments_count":{
"statistical":{
"field":"comments_count"
}
},
"likes_count":{
"statistical":{
"field":"likes_count"
}
},
"dislikes_count":{
"statistical":{
"field":"dislikes_count"
}
},
"advanced_stats":{
"terms_stats":{
"key_field":"brand_ids",
"value_script": doc['views_count'].value + doc['likes_count'].value + doc['dislikes_count'].value,
"size":5
}
}
},
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment