Last active
May 28, 2018 10:57
-
-
Save xeraa/39643754163a414b94e819161e18f208 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Data | |
DELETE latest-connection | |
POST _bulk | |
{ "index" : { "_index" : "latest-connection", "_type" : "_doc"} } | |
{ "client": "10.10.10.10", "version": "1.3", "timestamp": "2018-05-01T12:10:30Z" } | |
{ "index" : { "_index" : "latest-connection", "_type" : "_doc"} } | |
{ "client": "20.20.20.20", "version": "1.5", "timestamp": "2018-05-01T12:10:30Z" } | |
{ "index" : { "_index" : "latest-connection", "_type" : "_doc"} } | |
{ "client": "10.10.10.10", "version": "1.4", "timestamp": "2018-05-02T12:10:30Z" } | |
{ "index" : { "_index" : "latest-connection", "_type" : "_doc"} } | |
{ "client": "10.10.10.10", "version": "1.4", "timestamp": "2018-05-03T12:10:30Z" } | |
{ "index" : { "_index" : "latest-connection", "_type" : "_doc"} } | |
{ "client": "30.30.30.30", "version": "1.0", "timestamp": "2018-05-03T10:10:30Z" } | |
{ "index" : { "_index" : "latest-connection", "_type" : "_doc"} } | |
{ "client": "30.30.30.30", "version": "1.3", "timestamp": "2018-05-03T12:10:30Z" } | |
{ "index" : { "_index" : "latest-connection", "_type" : "_doc"} } | |
{ "client": "20.20.20.20", "version": "1.5", "timestamp": "2018-05-04T12:10:30Z" } | |
{ "index" : { "_index" : "latest-connection", "_type" : "_doc"} } | |
{ "client": "20.20.20.20", "version": "1.6", "timestamp": "2018-05-04T12:11:30Z" } | |
# Simple | |
GET latest-connection/_search | |
{ | |
"query": { | |
"match_all": { } | |
}, | |
"collapse" : { | |
"field" : "client.keyword" | |
}, | |
"sort": [{"timestamp": "desc"}] | |
} | |
# Slightly more advanced | |
GET latest-connection/_search | |
{ | |
"query": { | |
"match_all": { } | |
}, | |
"collapse" : { | |
"field" : "client.keyword", | |
"inner_hits": { | |
"name": "last_connection", | |
"size": 1, | |
"sort": [{"timestamp": "desc"}] | |
} | |
}, | |
"sort": [{"client.keyword": "asc"}, {"timestamp": "desc"}] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment