1
0

span-not-query.asciidoc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. [[query-dsl-span-not-query]]
  2. === Span Not Query
  3. Removes matches which overlap with another span query. The span not
  4. query maps to Lucene `SpanNotQuery`. Here is an example:
  5. [source,js]
  6. --------------------------------------------------
  7. {
  8. "span_not" : {
  9. "include" : {
  10. "span_term" : { "field1" : "hoya" }
  11. },
  12. "exclude" : {
  13. "span_near" : {
  14. "clauses" : [
  15. { "span_term" : { "field1" : "la" } },
  16. { "span_term" : { "field1" : "hoya" } }
  17. ],
  18. "slop" : 0,
  19. "in_order" : true
  20. }
  21. }
  22. }
  23. }
  24. --------------------------------------------------
  25. The `include` and `exclude` clauses can be any span type query. The
  26. `include` clause is the span query whose matches are filtered, and the
  27. `exclude` clause is the span query whose matches must not overlap those
  28. returned.
  29. In the above example all documents with the term hoya are filtered except the ones that have 'la' preceding them.
  30. Other top level options:
  31. [horizontal]
  32. `pre`:: If set the amount of tokens before the include span can't have overlap with the exclude span.
  33. `post`:: If set the amount of tokens after the include span can't have overlap with the exclude span.
  34. `dist`:: If set the amount of tokens from within the include span can't have overlap with the exclude span. Equivalent
  35. of setting both `pre` and `post`.