OpenSearch/docs/reference/query-dsl/fuzzy-query.asciidoc
Adrien Grand 864ed04059 Lessen leniency of the query dsl. #18276
This change does the following:
 - Queries that are currently unsupported such as prefix queries on numeric
   fields or term queries on geo fields now throw an error rather than returning
   a query that does not match anything.
 - Fuzzy queries on numeric, date and ip fields are now unsupported: they used
   to create range queries, we now expect users to use range queries directly.
   Fuzzy, regexp and prefix queries are now only supported on text/keyword
   fields (including `_all`).
 - The `_uid` and `_id` fields do not support prefix or range queries anymore as
   it would prevent us to store them more efficiently in the future, eg. by
   using a binary encoding.

Note that it is still possible to ignore these errors by using the `lenient`
option of the `match` or `query_string` queries.
2016-05-16 17:37:00 +02:00

65 lines
1.6 KiB
Plaintext

[[query-dsl-fuzzy-query]]
=== Fuzzy Query
deprecated[5.0.0, Will be removed in 6.0. Use match queries with fuzziness instead]
The fuzzy query uses similarity based on Levenshtein edit distance.
==== String fields
The `fuzzy` query generates all possible matching terms that are within the
maximum edit distance specified in `fuzziness` and then checks the term
dictionary to find out which of those generated terms actually exist in the
index.
Here is a simple example:
[source,js]
--------------------------------------------------
{
"fuzzy" : { "user" : "ki" }
}
--------------------------------------------------
Or with more advanced settings:
[source,js]
--------------------------------------------------
{
"fuzzy" : {
"user" : {
"value" : "ki",
"boost" : 1.0,
"fuzziness" : 2,
"prefix_length" : 0,
"max_expansions": 100
}
}
}
--------------------------------------------------
[float]
===== Parameters
[horizontal]
`fuzziness`::
The maximum edit distance. Defaults to `AUTO`. See <<fuzziness>>.
`prefix_length`::
The number of initial characters which will not be ``fuzzified''. This
helps to reduce the number of terms which must be examined. Defaults
to `0`.
`max_expansions`::
The maximum number of terms that the `fuzzy` query will expand to.
Defaults to `50`.
WARNING: This query can be very heavy if `prefix_length` is set to `0` and if
`max_expansions` is set to a high number. It could result in every term in the
index being examined!