You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: en/reference/query-language-reference.html
+41-13Lines changed: 41 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -248,24 +248,39 @@ <h2 id="where">where</h2>
248
248
<th>near</th>
249
249
<td>
250
250
<pid="near">
251
-
<code>near()</code> matches if all argument terms occur close to each other in the same document.
251
+
<code>near()</code> matches if all argument terms occur within the specified distance,
252
+
in any order. Negative terms (prefixed with <code>!</code>) exclude matches where those terms
253
+
appear within the exclusion distance.
252
254
</p>
255
+
<pre>
256
+
where field contains near("a", "b", "c")
257
+
where field contains ({distance: 5}near("web", "search"))
258
+
where field contains near("sql", "database", !"nosql")
259
+
</pre>
253
260
<tableclass="table">
254
261
<thead>
255
262
<tr>
256
263
<th>Annotation</th>
257
-
<th>Effect</th>
264
+
<th>Default</th>
265
+
<th>Description</th>
258
266
</tr>
259
267
</thead>
260
268
<tbody>
261
269
<tr>
262
270
<td><ahref="#distance">distance</a></td>
263
-
<td>Tune closeness using <code>distance</code>.</td>
271
+
<td>2</td>
272
+
<td>Maximum position difference for terms to match.</td>
273
+
</tr>
274
+
<tr>
275
+
<td>exclusionDistance</td>
276
+
<td>(distance+1)/2</td>
277
+
<td>Exclusion zone size around negative terms.</td>
264
278
</tr>
265
279
</tbody>
266
280
</table>
267
281
<p>
268
-
For multi-value fields, setting <ahref="schema-reference.html#rank-element-gap">element-gap</a> for the field in the rank profile enables distance calculation between adjacent elements.
282
+
Negative terms must come after all positive terms.
283
+
For multi-value fields, setting <ahref="schema-reference.html#rank-element-gap">element-gap</a> for the field in the rank profile enables distance calculation between adjacent elements.
269
284
</p>
270
285
</td>
271
286
</tr>
@@ -275,26 +290,38 @@ <h2 id="where">where</h2>
275
290
<td>
276
291
<pid="onear">
277
292
<code>onear()</code> (ordered near) is like <code>near()</code>,
278
-
but also requires the terms in the document having the same order
279
-
as given in the function (i.e. it is a phrase allowing other words interleaved).
280
-
With distance 1, <code>onear()</code> has the same semantics as <code>phrase()</code>.
293
+
but requires terms to appear in the same order as specified in the query.
294
+
With distance set to (number of terms - 1), <code>onear()</code> is equivalent to <code>phrase()</code>.
281
295
</p>
282
-
<tableclass="table"><!-- ToDo: Assuming near and onear support the same annotations -->
296
+
<pre>
297
+
where field contains onear("web", "search", "engine")
298
+
where field contains ({distance: 5}onear("neural", "network"))
299
+
where field contains onear("java", "tutorial", !"script")
300
+
</pre>
301
+
<tableclass="table">
283
302
<thead>
284
303
<tr>
285
304
<th>Annotation</th>
286
-
<th>Effect</th>
305
+
<th>Default</th>
306
+
<th>Description</th>
287
307
</tr>
288
308
</thead>
289
309
<tbody>
290
310
<tr>
291
311
<td><ahref="#distance">distance</a></td>
292
-
<td>Tune closeness using <code>distance</code>.</td>
312
+
<td>2</td>
313
+
<td>Maximum position difference for terms to match.</td>
314
+
</tr>
315
+
<tr>
316
+
<td>exclusionDistance</td>
317
+
<td>(distance+1)/2</td>
318
+
<td>Exclusion zone size around negative terms.</td>
293
319
</tr>
294
320
</tbody>
295
321
</table>
296
322
<p>
297
-
For multi-value fields, setting <ahref="schema-reference.html#rank-element-gap">element-gap</a> for the field in the rank profile enables distance calculation between adjacent elements.
323
+
Negative terms must come after all positive terms.
324
+
For multi-value fields, setting <ahref="schema-reference.html#rank-element-gap">element-gap</a> for the field in the rank profile enables distance calculation between adjacent elements.
0 commit comments