> For the complete documentation index, see [llms.txt](https://xiaoxiami.gitbook.io/elasticsearch/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xiaoxiami.gitbook.io/elasticsearch/ji-chu/35query-dsldslfang-shi-cha-8be229/358span-cha-xun/span-near-cha-xun.md).

# Span Near 查询

彼此接近的匹配跨距。可以指定坡度，中间不匹配位置的最大数量，以及匹配是否需要排序。查询的范围映射到Lucene SpanNearQuery。这是一个例子：

```
GET /_search
{
    "query": {
        "span_near" : {
            "clauses" : [
                { "span_term" : { "field" : "value1" } },
                { "span_term" : { "field" : "value2" } },
                { "span_term" : { "field" : "value3" } }
            ],
            "slop" : 12,
            "in_order" : false
        }
    }
}
```

clauses元素是一个或多个其他span类型查询的列表，而slop控制允许的中间不匹配位置的最大数量。
