I have a very tiny index (around 10 documents), having some important information, being one of them an attribute called number_of_days.
What I am trying to do is run a simple query to retrieve document with the bigger number in that attribute. Something like this:
elasticsearch {
hosts => ["server1:9200"]
index => "expiration"
query => '{"query": {"match_all": {}},"size": 0,"aggs" : {"max_expiration" : { "max" : { "field" : "days_to_expire" } }}}'
fields => { "max_expiration" => "[@metadata][max_expiration]" }
}
However it is not working, and reading though other topics, it seems that logstash doesn't work with aggregations. So, how can I fix this problem? I mean, get the biggest number from an index, and assign that value to a variable?
Thanks,
Rob