Combining Fuzziness (Levenshtein distance) of multiple fields into one


(DavidEq) #1

Hello,

I was googling and reading documentation for hours and still could not figure out...

Below data exists

"firstname" : "Michael",
"lastname" : "Jackson"

PROBLEM:
"query":"firstname:Michaelaa~ AND lastname:Jacksonaa~"
This is a Levenshtein distance of a 2 for first name and 2 for last name. Combined it's a 4.

Is there a way I get only results returned for a combined Levenshtein distance of 2 or below of multiple fields?

QUERY:

GET mjc0601/_search
{
"query":{
"bool":{
"must":[
{
"query_string":{
"query":"firstname:Michaelaa~ AND lastname:Jacksonaa~",
"fuzzy_prefix_length":0,
"fuzziness":2,
"fuzzy_transpositions": true,
"fuzzy_max_expansions": 100
}
}
]
}
}
}

Result:

{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.9902103,
"hits": [
{
"_index": "mjc0601",
"_type": "person",
"_id": "_HXZu2MBpzH4ZCxFqWkc",
"_score": 0.9902103,
"_source": {
"firstname": "Michael",
"lastname": "Jackson"
}
}
]
}
}

Expectation:
Not returning any results b/c combined fuzziness is a 4..

Thank you.


(Mark Harwood) #2

This is a per-term setting and for performance reasons the max fuzziness value is 2


(system) #3

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