elasticsearch/docs/reference/query-languages/query-dsl/span-queries.md
Craig Taverner 94cad286bc
Restructure query-languages docs files for clarity (#124797)
In a few previous PR's we restructured the ES|QL docs to make it possible to generate them dynamically.

This PR just moves a few files around to make the query languages docs easier to work with, and a little more organized like the ES|QL docs.

A bit part of this was setting up redirects to the new locations, so other repo's could correctly link to the elasticsearch docs.
2025-03-17 17:58:58 +01:00

51 lines
3 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
mapped_pages:
- https://www.elastic.co/guide/en/elasticsearch/reference/current/span-queries.html
---
# 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.
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.
Span queries cannot be mixed with non-span queries (with the exception of the `span_multi` query).
The queries in this group are:
[`span_containing` query](/reference/query-languages/query-dsl/query-dsl-span-containing-query.md)
: Accepts a list of span queries, but only returns those spans which also match a second span query.
[`span_field_masking` query](/reference/query-languages/query-dsl/query-dsl-span-field-masking-query.md)
: Allows queries like `span-near` or `span-or` across different fields.
[`span_first` query](/reference/query-languages/query-dsl/query-dsl-span-first-query.md)
: Accepts another span query whose matches must appear within the first N positions of the field.
[`span_multi` query](/reference/query-languages/query-dsl/query-dsl-span-multi-term-query.md)
: Wraps a [`term`](/reference/query-languages/query-dsl/query-dsl-term-query.md), [`range`](/reference/query-languages/query-dsl/query-dsl-range-query.md), [`prefix`](/reference/query-languages/query-dsl/query-dsl-prefix-query.md), [`wildcard`](/reference/query-languages/query-dsl/query-dsl-wildcard-query.md), [`regexp`](/reference/query-languages/query-dsl/query-dsl-regexp-query.md), or [`fuzzy`](/reference/query-languages/query-dsl/query-dsl-fuzzy-query.md) query.
[`span_near` query](/reference/query-languages/query-dsl/query-dsl-span-near-query.md)
: Accepts multiple span queries whose matches must be within the specified distance of each other, and possibly in the same order.
[`span_not` query](/reference/query-languages/query-dsl/query-dsl-span-not-query.md)
: Wraps another span query, and excludes any documents which match that query.
[`span_or` query](/reference/query-languages/query-dsl/query-dsl-span-query.md)
: Combines multiple span queriesreturns documents which match any of the specified queries.
[`span_term` query](/reference/query-languages/query-dsl/query-dsl-span-term-query.md)
: The equivalent of the [`term` query](/reference/query-languages/query-dsl/query-dsl-term-query.md) but for use with other span queries.
[`span_within` query](/reference/query-languages/query-dsl/query-dsl-span-within-query.md)
: 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.