Created
December 3, 2014 10:52
-
-
Save duydo/844d35d740833fb816a1 to your computer and use it in GitHub Desktop.
elasticsearch aggs top_hits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XGET "http://ext-es2.ssh.sentifi.com:9200/analytic/relevant_document/_search" -d' | |
{ | |
"size": 0, | |
"query": { | |
"range": { | |
"date": { | |
"from": "now-1h" | |
} | |
} | |
}, | |
"aggs": { | |
"0": { | |
"filter": { | |
"bool": { | |
"must": [ | |
{ | |
"exists": { | |
"field": "tag" | |
} | |
}, | |
{ | |
"script": { | |
"script": "doc[\"tag\"].values.length > 1" | |
} | |
} | |
] | |
} | |
}, | |
"aggs": { | |
"1": { | |
"terms": { | |
"size": 0, | |
"lang": "groovy", | |
"script": "doc[\"tag\"].values.join(\"-\")" | |
}, | |
"aggs": { | |
"2": { | |
"top_hits": { | |
"sort": [ | |
{ | |
"date": { | |
"order": "desc" | |
} | |
} | |
], | |
"size": 5, | |
"_source": { | |
"include": [ | |
"text" | |
] | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment