fuzzy-query.asciidoc 1.6 KB

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