diff --git a/en/reference/query-language-reference.html b/en/reference/query-language-reference.html index f4e200e1a0..736d592ce8 100644 --- a/en/reference/query-language-reference.html +++ b/en/reference/query-language-reference.html @@ -248,24 +248,39 @@
- near() matches if all argument terms occur close to each other in the same document.
+ near() matches if all argument terms occur within the specified distance,
+ in any order. Negative terms (prefixed with !) exclude matches where those terms
+ appear within the exclusion distance.
+where field contains near("a", "b", "c")
+where field contains ({distance: 5}near("web", "search"))
+where field contains near("sql", "database", !"nosql")
+
| Annotation | -Effect | +Default | +Description |
|---|---|---|---|
| distance | -Tune closeness using distance. |
+ 2 | +Maximum position difference for terms to match. | +
| exclusionDistance | +(distance+1)/2 | +Exclusion zone size around negative terms. |
- For multi-value fields, setting element-gap for the field in the rank profile enables distance calculation between adjacent elements. + Negative terms must come after all positive terms. + For multi-value fields, setting element-gap for the field in the rank profile enables distance calculation between adjacent elements.
onear() (ordered near) is like near(),
- but also requires the terms in the document having the same order
- as given in the function (i.e. it is a phrase allowing other words interleaved).
- With distance 1, onear() has the same semantics as phrase().
+ but requires terms to appear in the same order as specified in the query.
+ With distance set to (number of terms - 1), onear() is equivalent to phrase().
| Annotation | -Effect | +Default | +Description |
|---|---|---|---|
| distance | -Tune closeness using distance. |
+ 2 | +Maximum position difference for terms to match. | +
| exclusionDistance | +(distance+1)/2 | +Exclusion zone size around negative terms. |
- For multi-value fields, setting element-gap for the field in the rank profile enables distance calculation between adjacent elements. + Negative terms must come after all positive terms. + For multi-value fields, setting element-gap for the field in the rank profile enables distance calculation between adjacent elements.
@@ -1704,9 +1731,10 @@- The distance-annotation sets the maximum position difference to count as a match, + The distance annotation sets the maximum position difference to count as a match, see near / onear. - The default distance is 2, meaning match if the words have up to one separating word. + All matching terms must fit within positions [P, P+distance] where P is the first term's position. + Default is 2.
where text contains ({distance: 5}near("a", "b"))