span-not-query.asciidoc 1.0 KB

123456789101112131415161718192021222324252627282930313233
  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.