Hello,
I want to do search an index with multiple values. I want to also know which search result comes for which searched value. Can I do this in case of terms query.
e.g.
GET /_search
{
"query": {
"terms": {
"user.id": [ "kimchy", "elkbee" ],
"boost": 1.0
}
}
}
expected output (including for_searched_value):
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "teachers",
"_type": "_doc",
"_id": "f3822b08-27c4-485a-adce-cec2af1b19b4",
"_score": 1,
"_source": {
"user": {
"id": "kimchy"
},
"subject": "English"
},
"for_searched_value": "kimchy"
},
{
"_index": "teachers",
"_type": "_doc",
"_id": "f3822b08-27c4-485a-adce-cec2af1b19b4",
"_score": 1,
"_source": {
"user": {
"id": "kimchy"
},
"subject": "Physics"
},
"for_searched_value": "kimchy"
},
{
"_index": "teachers",
"_type": "_doc",
"_id": "f3822b08-27c4-485a-adce-cec2af1b19b4",
"_score": 1,
"_source": {
"user": {
"id": "elkbee"
},
"subject": "Math"
},
"for_searched_value": "elkbee"
}
]
}
}
Is there any way to know similar information like matched value for every search hit from code. I am using flask for my application.