@@ -397,68 +397,3 @@ This query does *not* match a document containing the phrase `hot porridge is
397
397
salty porridge`, because the intervals returned by the match query for `hot
398
398
porridge` only cover the initial two terms in this document, and these do not
399
399
overlap the intervals covering `salty`.
400
-
401
- Another restriction to be aware of is the case of `any_of` rules that contain
402
- sub-rules which overlap. In particular, if one of the rules is a strict
403
- prefix of the other, then the longer rule can never match, which can
404
- cause surprises when used in combination with `max_gaps`. Consider the
405
- following query, searching for `the` immediately followed by `big` or `big bad`,
406
- immediately followed by `wolf`:
407
-
408
- [source,console]
409
- --------------------------------------------------
410
- POST _search
411
- {
412
- "query": {
413
- "intervals" : {
414
- "my_text" : {
415
- "all_of" : {
416
- "intervals" : [
417
- { "match" : { "query" : "the" } },
418
- { "any_of" : {
419
- "intervals" : [
420
- { "match" : { "query" : "big" } },
421
- { "match" : { "query" : "big bad" } }
422
- ] } },
423
- { "match" : { "query" : "wolf" } }
424
- ],
425
- "max_gaps" : 0,
426
- "ordered" : true
427
- }
428
- }
429
- }
430
- }
431
- }
432
- --------------------------------------------------
433
-
434
- Counter-intuitively, this query does *not* match the document `the big bad
435
- wolf`, because the `any_of` rule in the middle only produces intervals
436
- for `big` - intervals for `big bad` being longer than those for `big`, while
437
- starting at the same position, and so being minimized away. In these cases,
438
- it's better to rewrite the query so that all of the options are explicitly
439
- laid out at the top level:
440
-
441
- [source,console]
442
- --------------------------------------------------
443
- POST _search
444
- {
445
- "query": {
446
- "intervals" : {
447
- "my_text" : {
448
- "any_of" : {
449
- "intervals" : [
450
- { "match" : {
451
- "query" : "the big bad wolf",
452
- "ordered" : true,
453
- "max_gaps" : 0 } },
454
- { "match" : {
455
- "query" : "the big wolf",
456
- "ordered" : true,
457
- "max_gaps" : 0 } }
458
- ]
459
- }
460
- }
461
- }
462
- }
463
- }
464
- --------------------------------------------------
0 commit comments