Skip to content

Instantly share code, notes, and snippets.

@fabien7337
Last active December 23, 2015 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabien7337/6581373 to your computer and use it in GitHub Desktop.
Save fabien7337/6581373 to your computer and use it in GitHub Desktop.
Multiple value in a terms stats
curl -X GET '127.0.0.1:9200/octoly-development-videos/video/_search?from=0&size=20&pretty' -d '{
"query":{
"bool":{
"must":[
{
"query_string":{
"query":"*",
"default_operator":"AND"
}
}
],
"should":[
{
"bool":{}
}
],
"minimum_should_match":1
}
},
"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
}
}
},
"size":20,
"from":0
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment