2015-06-03 19:59:22 -04:00
|
|
|
[[span-queries]]
|
|
|
|
== Span queries
|
|
|
|
|
|
|
|
Span queries are low-level positional queries which provide expert control
|
|
|
|
over the order and proximity of the specified terms. These are typically used
|
|
|
|
to implement very specific queries on legal documents or patents.
|
|
|
|
|
2018-11-26 12:15:59 -05:00
|
|
|
It is only allowed to set boost on an outer span query. Compound span queries,
|
|
|
|
like span_near, only use the list of matching spans of inner span queries in
|
|
|
|
order to find their own spans, which they then use to produce a score. Scores
|
|
|
|
are never computed on inner span queries, which is the reason why boosts are not
|
|
|
|
allowed: they only influence the way scores are computed, not spans.
|
|
|
|
|
2015-06-03 19:59:22 -04:00
|
|
|
Span queries cannot be mixed with non-span queries (with the exception of the `span_multi` query).
|
|
|
|
|
|
|
|
The queries in this group are:
|
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
<<query-dsl-span-containing-query,`span_containing` query>>::
|
|
|
|
Accepts a list of span queries, but only returns those spans which also match a second span query.
|
2015-06-03 19:59:22 -04:00
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
<<query-dsl-span-field-masking-query,`field_masking_span` query>>::
|
|
|
|
Allows queries like `span-near` or `span-or` across different fields.
|
2015-06-03 19:59:22 -04:00
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
<<query-dsl-span-first-query,`span_first` query>>::
|
|
|
|
Accepts another span query whose matches must appear within the first N
|
|
|
|
positions of the field.
|
2015-06-03 19:59:22 -04:00
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
<<query-dsl-span-multi-term-query,`span_multi` query>>::
|
2015-06-03 19:59:22 -04:00
|
|
|
Wraps a <<query-dsl-term-query,`term`>>, <<query-dsl-range-query,`range`>>,
|
|
|
|
<<query-dsl-prefix-query,`prefix`>>, <<query-dsl-wildcard-query,`wildcard`>>,
|
|
|
|
<<query-dsl-regexp-query,`regexp`>>, or <<query-dsl-fuzzy-query,`fuzzy`>> query.
|
|
|
|
|
|
|
|
<<query-dsl-span-near-query,`span_near` query>>::
|
|
|
|
Accepts multiple span queries whose matches must be within the specified distance of each other, and possibly in the same order.
|
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
<<query-dsl-span-not-query,`span_not` query>>::
|
|
|
|
Wraps another span query, and excludes any documents which match that query.
|
2015-06-03 19:59:22 -04:00
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
<<query-dsl-span-or-query,`span_or` query>>::
|
2015-06-03 19:59:22 -04:00
|
|
|
Combines multiple span queries -- returns documents which match any of the
|
|
|
|
specified queries.
|
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
<<query-dsl-span-term-query,`span_term` query>>::
|
2015-06-03 19:59:22 -04:00
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
The equivalent of the <<query-dsl-term-query,`term` query>> but for use with
|
|
|
|
other span queries.
|
2015-06-03 19:59:22 -04:00
|
|
|
|
|
|
|
<<query-dsl-span-within-query,`span_within` query>>::
|
|
|
|
The result from a single span query is returned as long is its span falls
|
|
|
|
within the spans returned by a list of other span queries.
|
|
|
|
|
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
include::span-containing-query.asciidoc[]
|
2015-06-03 19:59:22 -04:00
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
include::span-field-masking-query.asciidoc[]
|
2015-06-03 19:59:22 -04:00
|
|
|
|
|
|
|
include::span-first-query.asciidoc[]
|
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
include::span-multi-term-query.asciidoc[]
|
2015-06-03 19:59:22 -04:00
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
include::span-near-query.asciidoc[]
|
2015-06-03 19:59:22 -04:00
|
|
|
|
|
|
|
include::span-not-query.asciidoc[]
|
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
include::span-or-query.asciidoc[]
|
2015-06-03 19:59:22 -04:00
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
include::span-term-query.asciidoc[]
|
2016-09-13 07:27:33 -04:00
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
include::span-within-query.asciidoc[]
|