Hello, I have a tricky case and want to consult the experts here.
We store our user info in Elasticsearch, an user may have different name aliases, all stored in a "names" array like below
"names" : [
{
"userName" : "John Jerry",
"nameType" : "Primary Name"
},
{
"userName" : "John The Great",
"nameType" :"Also Known As"
},
{
"userName" : "Jerry Our Father",
"nameType" :"Also Known As"
}
]
When we search for a user name, let say "jone great" we build a fuzzysearch like below
{
"span_near": {
"clauses": [
{
"span_multi": {
"match": {
"fuzzy": {
"names.userName": {
"value": "jone",
"fuzziness": "1",
"prefix_length": 0,
"max_expansions": 50,
"transpositions": true,
"boost": 1
}
}
},
"boost": 1
}
},
{
"span_multi": {
"match": {
"fuzzy": {
"names.userName": {
"value": "great",
"fuzziness": "1",
"prefix_length": 0,
"max_expansions": 50,
"transpositions": true,
"boost": 1
}
}
},
"boost": 1
}
}
],
"slop": 2,
"in_order": false,
"boost": 1
}
},
This query will return the user above, whose alias is "John The Great" because this name has a good score against the input "jone great"
The question is how do I know programmatically which name in the array is chosen by the fuzzysearch. Imagine a user has 100 name aliases, is there a way to tell Elasticsearch to point out which alias is the reason that user is chosen as a match?