Get value in the database based on the condition


(Maria Thanaraj) #1

It is possible to get value in the database, passing the different username to get resent value for how many usernames we are passing


(David Pilato) #2

I don't understand the question. May be clarify with an example?


(Maria Thanaraj) #3

in my database, I am store every one minute once some information, the information like
{
"_index": "location_list",
"_type": "history",
"_id": "1OD--GMBwqsaEQg-BLMR",
"_score": 1,
"_source": {
"mLatitude": 9.93512894,
"mLongitude": 78.13338479,
"username": "security1",
"mTimestamp": "2018/06/13 17:23:06"
}

Here the username will be change ramdomly, for example ** {
"_index": "location_list",
"_type": "history",
"_id": "1OD--GMBwqsaEQg-BLMR",
"_score": 1,
"_source": {
"mLatitude": 9.93512894,
"mLongitude": 78.13338479,
"username": "maria",
"mTimestamp": "2018/06/13 17:23:06"
}
},
{
"_index": "location_list",
"_type": "history",
"_id": "1eD--GMBwqsaEQg-B7Mm",
"_score": 1,
"_source": {
"mLatitude": 9.93454862,
"mLongitude": 78.1338991,
"username": "thanaraj",
"mTimestamp": "2018/06/13 17:23:07"
}
},
{
"_index": "location_list",
"_type": "history",
"_id": "veD9-GMBwqsaEQg-nbN3",
"_score": 1,
"_source": {
"mLatitude": 9.93462449,
"mLongitude": 78.13383332,
"username": "maria",
"mTimestamp": "2018/06/13 17:22:40"
}
},
{
"_index": "location_list",
"_type": "history",
"_id": "wuD9-GMBwqsaEQg-sbMn",
"_score": 1,
"_source": {
"mLatitude": 9.93512817,
"mLongitude": 78.13361752,
"username": "maria",
"mTimestamp": "2018/06/13 17:22:45"
}**
Here two user one maria another one thanaraj, i need query to retrive data in database for recent entery for the two user ..


(Christian Dahlqvist) #4

If you are frequently looking for the most recent entry, you could create a separate index where you store documents with the username as id. As new locations for a user comes in, the users record would get updated in this index. You can then use the existing index to track locations over time and the other to efficiently get the last known location.


(Maria Thanaraj) #5

thank you


(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.