i'm trying first document has specific property. example have 50 docs property "a":"1", different dates. 100 docs "a":"2" there way query first doc of each "a" value date?
not wanted, run following show results match a:1 or a:2 , order results wanted.
{ "sort": { "your_timestamp_field": { "order": "desc" } }, "query": { "filtered": { "filter": { "or": [ { "term": { "a": 1 } }, { "term": { "a": 2 } } ] } } } }
you run multiple queries using msearch
. example
place below in file named requests
{"index": "your-index"} {"size":1,"sort":{"@timestamp":{"order":"desc"}},"query":{"filtered":{"filter":{"term":{"a":"1"}}}}} {"index": "your-index"} {"size":1,"sort":{"@timestamp":{"order":"desc"}},"query":{"filtered":{"filter":{"term":{"a":"2"}}}}}
then run
curl -xget http://localhost:9200/your-index/_msearch --data-binary @requests; echo