Hello elasticsearch pioneers,
I would like the results to be in the same sequence as the query. To elaborate more about this, consider the following example. :
I have documents with ID field, which look somewhat like this :
{
{
"ID": 102,
"Name": "Mark"
},
{
"ID": 104,
"Name": "Pete"
},
{
"ID": 101,
"Name": "Su"
},
{
"ID": 107,
"Name": "Kate"
},
{
"ID": 106,
"Name": "Roger"
}
}
And my query is:
{
"query": {
"bool": {
"should": [
{
"match":
{
"ID": "101"
}
},
{
"match":
{
"ID": "104"
}
},
{
"match":
{
"ID": "107"
}
},
{
"match":
{
"ID": "102"
}
},
{
"match":
{
"ID": "106"
}
}
]
}
}
}
Now I'm expecting the results to be in the same order as the search criteria. i.e :
{
"ID": 101,
"Name": "Su"
},
{
"ID": 104,
"Name": "Pete"
},
{
"ID": 107,
"Name": "Kate"
},
{
"ID": 102,
"Name": "Mark"
},
{
"ID": 106,
"Name": "Roger"
}
Been trying to figure out a way to do this. Is it even possible? Any help appreciated.