fuzzy-query.asciidoc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. GET /_search
  14. {
  15. "query": {
  16. "fuzzy" : { "user" : "ki" }
  17. }
  18. }
  19. --------------------------------------------------
  20. // CONSOLE
  21. // TEST[warning:fuzzy query is deprecated. Instead use the [match] query with fuzziness parameter]
  22. Or with more advanced settings:
  23. [source,js]
  24. --------------------------------------------------
  25. GET /_search
  26. {
  27. "query": {
  28. "fuzzy" : {
  29. "user" : {
  30. "value" : "ki",
  31. "boost" : 1.0,
  32. "fuzziness" : 2,
  33. "prefix_length" : 0,
  34. "max_expansions": 100
  35. }
  36. }
  37. }
  38. }
  39. --------------------------------------------------
  40. // CONSOLE
  41. // TEST[warning:fuzzy query is deprecated. Instead use the [match] query with fuzziness parameter]
  42. [float]
  43. ===== Parameters
  44. [horizontal]
  45. `fuzziness`::
  46. The maximum edit distance. Defaults to `AUTO`. See <<fuzziness>>.
  47. `prefix_length`::
  48. The number of initial characters which will not be ``fuzzified''. This
  49. helps to reduce the number of terms which must be examined. Defaults
  50. to `0`.
  51. `max_expansions`::
  52. The maximum number of terms that the `fuzzy` query will expand to.
  53. Defaults to `50`.
  54. WARNING: This query can be very heavy if `prefix_length` is set to `0` and if
  55. `max_expansions` is set to a high number. It could result in every term in the
  56. index being examined!