Adding Fuzziness to Bool Query

Hi. I am very new to ElasticSearch so please be gentle :slight_smile:

I have the following bool query which is working well for me:

"query":{
"bool": {
"should": [
{"match":
{"surname" : "JONES"}
},
{"match":
{
"person_id" : "653463546"
}
}
]
}
}
}'

I am wanting to add some fuzziness into the surname search to catch typos or spelling mistakes but no matter where I try and add: "fuzziness": "AUTO", it seems to error.

If anyone has a sec, please can you help to get this working.

Cheers

Duncs

Here is the right way to do the fuzziness in your query.

{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "surname" : {
              "query" :  "JONES",
              "fuzziness": "AUTO"
            }
          }
        },
        {
          "match": {
            "person_id": "653463546"
          }
        }
      ]
    }
  }
}
1 Like

Thanks so much. Makes sense looking at that syntax. Cheers for the prompt reply.

You are welcome, if you want to see more examples of how you can use the match query you can see the link.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html

Also a good query to take a look is the bool query, which make possible combination of queries.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html

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