Match String required in Response using Query Match

HI,
I am using below query for searching record in Elastic Search:

{
"query": {
"match" : {
"record" : {
"query" : "black or ball OR Wheel OR bonnet",
"fuzziness": "AUTO"
}
}
}
}

Result:

{
"took": 4,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 9,
"relation": "eq"
},
"max_score": 1.3177552,
"hits": [
{
"_index": "myrecord",
"_type": "_doc",
"_id": "LOuLrm0ByPp6hZHAC8ln",
"_score": 1.3177552,
"_source": {
"record": "Wheel"
}
},
{
"_index": "myrecord",
"_type": "_doc",
"_id": "J-tWrm0ByPp6hZHAlsmm",
"_score": 0.6931472,
"_source": {
"record": "Black Tire"
}
},
{
"_index": "myrecord",
"_type": "_doc",
"_id": "KOtWrm0ByPp6hZHA9cn5",
"_score": 0.6931472,
"_source": {
"record": "ball bearing"
}
},
{
"_index": "myrecord",
"_type": "_doc",
"_id": "KetXrm0ByPp6hZHANMlw",
"_score": 0.6931472,
"_source": {
"record": "bearing ball"
}
},
{
"_index": "myrecord",
"_type": "_doc",
"_id": "LeuLrm0ByPp6hZHAQMlZ",
"_score": 0.6931472,
"_source": {
"record": "Small Wheel"
}
},
{
"_index": "myrecord",
"_type": "_doc",
"_id": "JutWrm0ByPp6hZHAZsma",
"_score": 0.52354836,
"_source": {
"record": "Tire Black"
}
},
{
"_index": "myrecord",
"_type": "_doc",
"_id": "KutXrm0ByPp6hZHAi8nk",
"_score": 0.34611148,
"_source": {
"record": "Tire-Black D12 IN 23"
}
},
{
"_index": "myrecord",
"_type": "_doc",
"_id": "LuuLrm0ByPp6hZHA3Mn3",
"_score": 0.2876821,
"_source": {
"record": "bonnet"
}
},
{
"_index": "myrecord",
"_type": "_doc",
"_id": "K-tXrm0ByPp6hZHA4clE",
"_score": 0.23014566,
"_source": {
"record": "Blcak"
}
}
]
}
}

I need the match string (word) in the record result like:

           {
            "_index": "myrecord",
            "_type": "_doc",
            "_id": "KOtWrm0ByPp6hZHA9cn5",

            "matchString":"Ball"

            "_score": 0.6931472,
            "_source": {
                "record": "ball bearing"
            }
        }

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