Files
honeymoose f321dfedf5 同步完成!
**同步结果摘要**:

| 目录 | 同步前 | 同步后 | 官方 |
|------|--------|--------|------|
| aggregations | 40 | 65 | 64 |
| analyzers | 8 | 141 | 140 |
| api-reference | 97 | 186 | 174 |
| benchmark | 34 | 67 | 53 |
| clients | 17 | 18 | 18 |
| dashboards | 38 | 149 | 131 |
| data-prepper | 77 | 134 | 123 |
| im-plugin | 22 | 37 | 37 |
| ingest-pipelines | 27 | 52 | 51 |
| install-and-configure | 37 | 57 | 53 |
| ml-commons-plugin | 81 | 157 | 155 |
| observing-your-data | 39 | 73 | 66 |
| query-dsl | 40 | 77 | 75 |
| search-plugins | 80 | 139 | 95 |
| security-analytics | 22 | 47 | 46 |

**说明**:
- 本地文件数 > 官方:本地有一些官方已删除或重命名的文件
- 新增了约 **740 个英文文档文件**
- 已有文件保持不变(未覆盖)
2026-11-30 10:48:30 -05:00

3.5 KiB

layout, title, has_children, has_toc, nav_order, redirect_from
layout title has_children has_toc nav_order redirect_from
default Span queries true false 75
/opensearch/query-dsl/span-query/
/query-dsl/query-dsl/span-query/
/query-dsl/span-query/
/query-dsl/span/

Span queries

You can use span queries to perform precise positional searches. Span queries are low-level, specific queries that provide control over the order and proximity of specified query terms. They are primarily used to search legal documents and patents.

Span queries include the following query types:

Query type Description
Span containing Returns larger spans that contain smaller spans within them. The opposite of the span_within query.
Span field masking Allows span queries to work across different fields by making one field appear as another. Useful when the same text is indexed using different analyzers.
Span first Matches terms or phrases that appear within a specified number of positions from the start of a field.
Span multi-term Enables multi-term queries (like prefix, wildcard, or fuzzy) to work within span queries.
Span near Finds terms or phrases that appear within a specified distance of each other. Supports requiring matches to appear in a specific order.
Span not Excludes matches that overlap with another span query.
Span or Matches documents that satisfy any of the provided span queries.
Span term Matches a single term while maintaining position information for use in other span queries.
Span within Returns smaller spans that are enclosed by larger spans. The opposite of the span_containing query.

Setup

To try the examples in this section, use the following steps to configure an example index.

Step 1: Create an index

First, create an index for an e-commerce clothing website. The description field uses the default standard analyzer, while the description.stemmed subfield applies the english analyzer to enable stemming:

PUT /clothing
{
  "mappings": {
    "properties": {
      "description": {
        "type": "text",
        "analyzer": "standard",
        "fields": {
          "stemmed": {
            "type": "text",
            "analyzer": "english"
          }
        }
      }
    }
  }
}

{% include copy-curl.html %}

Step 2: Index data

Index sample documents into the index:

POST /clothing/_doc/1
{
  "description": "Long-sleeved dress shirt with a formal collar and button cuffs. "
}

{% include copy-curl.html %}

POST /clothing/_doc/2
{
  "description": "Beautiful long dress in red silk, perfect for formal events."
}

{% include copy-curl.html %}

POST /clothing/_doc/3
{
  "description": "Short-sleeved shirt with a button-down collar, can be dressed up or down."
}

{% include copy-curl.html %}

POST /clothing/_doc/4
{
  "description": "A set of two midi silk shirt dresses with long sleeves in black. "
}

{% include copy-curl.html %}