1
votes

I'm trying to run "fuzzy" query_string search, any ideas what might be wrong? Fuzziness parameter itself is valid for query_string and no exception is thrown.

Finds one result:

{
  "query": {
    "bool": {
      "should": {
        "query_string": {
          "default_field": "title",
          "query": "index"
        }
      }
    }
  }
}

Cannot find anything:

{
  "query": {
    "bool": {
      "should": {
        "query_string": {
          "default_field": "title",
          "query": "indexa",
          "fuzziness": 9000
        }
      }
    }
  }
}
1

1 Answers

1
votes

For a query string, you'd have to explicitly use the "fuzzy operator" ~.

Try:

    "query_string": {
      "default_field": "title",
      "query": "indexa~",
      "fuzziness": "AUTO"
    }

Alternatively, you can use a fuzzy match query if you know which field you're searching on and you don't need the query string capabilities (e.g. allowing the user to use operators like AND or OR or introduce custom boosts etc.)

    "match": {
      "title": {
        "query": "indexa",
        "fuzziness": "AUTO"
      }
    }

Also note that in both cases, fuzziness only accepts the values 1, 2 or AUTO, so 9000 is not a valid value.