fuzzy-query.asciidoc 1.7 KB

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