**同步结果摘要**: | 目录 | 同步前 | 同步后 | 官方 | |------|--------|--------|------| | 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 个英文文档文件** - 已有文件保持不变(未覆盖)
3.4 KiB
layout, title, parent, grand_parent, nav_order
| layout | title | parent | grand_parent | nav_order |
|---|---|---|---|---|
| default | Span multi-term | Span queries | Query DSL | 40 |
Span multi-term query
The span_multi query allows you to wrap a multi-term query (like wildcard, fuzzy, prefix, range, or regexp) as a span query. This enables you to use these more flexible matching queries within other span queries.
For example, you can use the span_multi query to:
- Find words with common prefixes near other terms.
- Match fuzzy variations of words within spans.
- Use regular expressions in span queries.
span_multiqueries can potentially match many terms. To avoid excessive memory usage, you can:
- Set the
rewriteparameter for the multi-term query.- Use the
top_terms_*rewrite method.- Consider enabling the
index_prefixesoption for the text field if you usespan_multionly for aprefixquery. This automatically rewrites anyprefixquery on the field into a single-term query that matches the indexed prefix. {: .note}
Example
To try the examples in this section, complete the setup steps. {: .tip}
The span_multi query uses the following syntax to wrap the prefix query:
"span_multi": {
"match": {
"prefix": {
"description": {
"value": "flutter"
}
}
}
}
The following query searches for words starting with "dress" near any form of "sleeve" within at most 5 words of each other:
GET /clothing/_search
{
"query": {
"span_near": {
"clauses": [
{
"span_multi": {
"match": {
"prefix": {
"description": {
"value": "dress"
}
}
}
}
},
{
"field_masking_span": {
"query": {
"span_term": {
"description.stemmed": "sleev"
}
},
"field": "description"
}
}
],
"slop": 5,
"in_order": false
}
}
}
{% include copy-curl.html %}
The query matches documents 1 ("Long-sleeved dress...") and 4 ("...dresses with long fluttered sleeves...") because "dress" and "long" occur within the maximum distance in both documents.
Response
{: .text-delta}{
"took": 5,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 1.7590723,
"hits": [
{
"_index": "clothing",
"_id": "1",
"_score": 1.7590723,
"_source": {
"description": "Long-sleeved dress shirt with a formal collar and button cuffs. "
}
},
{
"_index": "clothing",
"_id": "4",
"_score": 0.84792376,
"_source": {
"description": "A set of two midi silk shirt dresses with long fluttered sleeves in black. "
}
}
]
}
}
Parameters
The following table lists all top-level parameters supported by span_multi queries. All parameters are required.
| Parameter | Data type | Description |
|---|---|---|
match |
Object | The multi-term query to wrap (can be prefix, wildcard, fuzzy, range, or regexp). |