我希望能够使用geo_shape
过滤器(其中geojson是嵌套的子文档)搜索文档,并且只检索与地理过滤器匹配的1子文档(而不是整个文档)。我认为文档(特别是嵌套对象类型和嵌套查询/过滤器文档)表明这可以使用join:false。出于某种原因,我无法让它工作,我确信这是用户错误或缺乏理解。
在ES 90.5及以下是一个有效的例子。
有人能指出我正确的方向吗?
由于
curl -XDELETE http://es_server.com:9200/test
{"ok":true,"acknowledged":true}
curl -XPUT http://es_server.com:9200/test
{"ok":true,"acknowledged":true}
testtype
curl -XPUT http://es_server.com:9200/test/testtype/_mapping -d '{
"testtype": {
"properties": {
"entities": {
"type": "nested",
"properties": {
"geometry": {
"tree": "quadtree",
"type": "geo_shape",
"precision": "10m"
}
}
}
}
}
}'
{"ok":true,"acknowledged":true}
curl -XPUT http://es_server.com:9200/test/testtype/doc1 -d '{
"id": "doc1",
"entities": [
{
"geometry": {
"type": "Point",
"coordinates": [
0.0,
0.0
]
}
},
{
"geometry": {
"type": "Point",
"coordinates": [
180.0,
90.0
]
}
}
]
}'
curl -XGET http://es_server.com:9200/test/testtype/_search -d '{
"query": {
"filtered": {
"filter": {
"nested": {
"path": "entities",
"join": false,
"filter": {
"geo_shape": {
"entities.geometry": {
"shape": {
"type": "envelope",
"coordinates": [
[
-10.0,
10.0
],
[
10.0,
-10.0
]
]
}
}
}
}
}
},
"query": {
"match_all": {}
}
}
}
}'
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
curl -XGET http://es_server.com:9200/test/testtype/_search -d '{
"query": {
"filtered": {
"filter": {
"nested": {
"path": "entities",
"filter": {
"geo_shape": {
"entities.geometry": {
"shape": {
"type": "envelope",
"coordinates": [
[
-10.0,
10.0
],
[
10.0,
-10.0
]
]
}
}
}
}
}
},
"query": {
"match_all": {}
}
}
}
}'
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1.0,
"hits": [
{
"_index": "test",
"_type": "testtype",
"_id": "doc1",
"_score": 1.0,
"_source": {
"id": "doc1",
"entities": [
{
"geometry": {
"type": "Point",
"coordinates": [
0.0,
0.0
]
}
},
{
"geometry": {
"type": "Point",
"coordinates": [
180.0,
90.0
]
}
}
]
}
}
]
}
}