fuzzy-query.asciidoc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. [[query-dsl-fuzzy-query]]
  2. === Fuzzy Query
  3. deprecated[5.0.0, Will be removed in 6.0. Use match queries with fuzziness instead]
  4. The fuzzy query uses similarity based on Levenshtein edit distance.
  5. ==== String fields
  6. The `fuzzy` query generates all possible matching terms that are within the
  7. maximum edit distance specified in `fuzziness` and then checks the term
  8. dictionary to find out which of those generated terms actually exist in the
  9. index.
  10. Here is a simple example:
  11. [source,js]
  12. --------------------------------------------------
  13. {
  14. "fuzzy" : { "user" : "ki" }
  15. }
  16. --------------------------------------------------
  17. Or with more advanced settings:
  18. [source,js]
  19. --------------------------------------------------
  20. {
  21. "fuzzy" : {
  22. "user" : {
  23. "value" : "ki",
  24. "boost" : 1.0,
  25. "fuzziness" : 2,
  26. "prefix_length" : 0,
  27. "max_expansions": 100
  28. }
  29. }
  30. }
  31. --------------------------------------------------
  32. [float]
  33. ===== Parameters
  34. [horizontal]
  35. `fuzziness`::
  36. The maximum edit distance. Defaults to `AUTO`. See <<fuzziness>>.
  37. `prefix_length`::
  38. The number of initial characters which will not be ``fuzzified''. This
  39. helps to reduce the number of terms which must be examined. Defaults
  40. to `0`.
  41. `max_expansions`::
  42. The maximum number of terms that the `fuzzy` query will expand to.
  43. Defaults to `50`.
  44. WARNING: This query can be very heavy if `prefix_length` is set to `0` and if
  45. `max_expansions` is set to a high number. It could result in every term in the
  46. index being examined!