# Span Within 查询

原文链接 : [https://www.elastic.co/guide/en/elasticsearch/reference/5.4/query-dsl-span-within-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/query-dsl-span-within-query.html)

译文链接 : [http://www.apache.wiki/pages/viewpage.action?pageId=10029290](http://www.apache.wiki/pages/viewpage.action?pageId=10029290)

贡献者 : [片刻](/display/~jiangzhonglian) [ApacheCN](/display/~apachecn) [Apache中文网](/display/~apachechina)

返回在另一个span查询中包含的匹配。查询内的范围映射到Lucene SpanWithinQuery。这是一个例子：

```
GET /_search
{
    "query": {
        "span_within" : {
            "little" : {
                "span_term" : { "field1" : "foo" }
            },
            "big" : {
                "span_near" : {
                    "clauses" : [
                        { "span_term" : { "field1" : "bar" } },
                        { "span_term" : { "field1" : "baz" } }
                    ],
                    "slop" : 5,
                    "in_order" : true
                }
            }
        }
    }
}
```

big和little的子句可以是任何span类型查询。在big中从已关闭的little匹配跨度返回。