summaryrefslogtreecommitdiff
path: root/docs/reference/query-dsl/queries/fuzzy-query.asciidoc
diff options
context:
space:
mode:
authorHilko Bengen <bengen@debian.org>2014-06-07 12:02:12 +0200
committerHilko Bengen <bengen@debian.org>2014-06-07 12:02:12 +0200
commitd5ed89b946297270ec28abf44bef2371a06f1f4f (patch)
treece2d945e4dde69af90bd9905a70d8d27f4936776 /docs/reference/query-dsl/queries/fuzzy-query.asciidoc
downloadelasticsearch-d5ed89b946297270ec28abf44bef2371a06f1f4f.tar.gz
Imported Upstream version 1.0.3upstream/1.0.3
Diffstat (limited to 'docs/reference/query-dsl/queries/fuzzy-query.asciidoc')
-rw-r--r--docs/reference/query-dsl/queries/fuzzy-query.asciidoc102
1 files changed, 102 insertions, 0 deletions
diff --git a/docs/reference/query-dsl/queries/fuzzy-query.asciidoc b/docs/reference/query-dsl/queries/fuzzy-query.asciidoc
new file mode 100644
index 0000000..082f3f1
--- /dev/null
+++ b/docs/reference/query-dsl/queries/fuzzy-query.asciidoc
@@ -0,0 +1,102 @@
+[[query-dsl-fuzzy-query]]
+=== Fuzzy Query
+
+The fuzzy query uses similarity based on Levenshtein edit distance for
+`string` fields, and a `+/-` margin on numeric and date fields.
+
+==== 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 `0`.
+
+
+WARNING: this query can be very heavy if `prefix_length` and `max_expansions`
+are both set to their defaults of `0`. This could cause every term in the
+index to be examined!
+
+
+[float]
+==== Numeric and date fields
+
+Performs a <<query-dsl-range-query>> ``around'' the value using the
+`fuzziness` value as a `+/-` range, where:
+
+ -fuzziness <= field value <= +fuzziness
+
+For example:
+
+[source,js]
+--------------------------------------------------
+{
+ "fuzzy" : {
+ "price" : {
+ "value" : 12,
+ "fuzziness" : 2
+ }
+ }
+}
+--------------------------------------------------
+
+Will result in a range query between 10 and 14. Date fields support
+<<time-units,time values>>, eg:
+
+[source,js]
+--------------------------------------------------
+{
+ "fuzzy" : {
+ "created" : {
+ "value" : "2010-02-05T12:05:07",
+ "fuzziness" : "1d"
+ }
+ }
+}
+--------------------------------------------------
+
+See <<fuzziness>> for more details about accepted values.