Match query not return exact match as top result

I have data in elasticsearch, with field fullName :

  1. John Doe Doe
  2. John Doe
  3. Eric John Doe

When I do a match query against fullName, with this query

{
    "from": 0,
    "size": 20,
    "query": {
        "bool": {
            "must": [
                {
                    "match": {
                        "fullName": {
                            "query": "John Doe",
                            "operator": "AND",
                            "fuzziness": "AUTO"
                        }
                    }
                }
            ]
        }
    }
}

I expect to get John Doe (exact match) as first result.
Instead, the returned value is in this sequence:

  1. John Doe Doe
  2. Eric John Doe
  3. John Doe

Where the exact match is on the lowest result.

What should I do to put the exact match into first result?
I cannot use term query since I still need a fuzzy match on fullName

Thanks

Hi @Timotius_Pamungkas

You can mix term ad match inside a should and put a boost on your term so if the term hit it will be on top.

"query": {
        "bool": {
            "must": [
                  {"bool":{ "should":[
                     "term": {
            "fullName": {
                "value": "John Doe",
                "boost": 2
            }
        }
                   ]}},
                {
                    "match": {
                        "fullName": {
                            "query": "John Doe",
                            "operator": "AND",
                            "fuzziness": "AUTO"
                        }
                    }
                }
            ]
        }
    }

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