I have a very basic requirement. I am indexing the records based on timestamp.
E.g
{ "temperature": [value], "deviceID":[value] , Timestamp: [ts]}
{ "temperature": [value], "deviceID":[value],Timestamp: [ts] }
{ "temperature": [value], "deviceID":[value],Timestamp: [ts] }
These record/events are added every 1 minute. I would like to query ES and find out the last 10 records ordered by timestamp for a particular deviceID. So, the first record should be t-10, then t-9, then t-8, ...
{
"sort":[ {"Timestamp": { "order" : "asc" }} ],
"query": {
"bool": {
"must": {
"match": {
"deviceID": 1
}
},
"filter": {
"range": {
"Timestamp": {
"gte": "now-10m"
}
}
}
}
},
"_source" : [ "temperature","deviceID","Timestamp"]
}
I realized that every time it gives different results ... ( though it is sorted based on Timestamp ). It is not giving any definitive result if i run it multiple time.
Am i missing something obvious ?
Please advise as i am not an expert in ES query DSL.Preformatted text