我使用Elastic 7.x来存储这样的文档:
{
"id": "polygon_tests_01.ast-ORTHOMOSAIC",
"name": "tmpl_integration_test_GeoTIFF",
"region": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"coordinates": [[[-149.67474372431124,61.27942558978003],
[-149.65726554157862,60.993770332779064],
[-150.11544465434918,61.15680203118899],
[-149.87699170822603,61.28122531469481],
[-149.67474372431124,61.27942558978003]]],
"type": "Polygon"
},
"properties": {}
}
],
"type": "Feature",
"properties": {}
}
... more data...
}
尝试为它创建一个Map,我用途:
{
"mappings": {
"properties": {
"region": {
"properties": {
"features": {
"properties": {
"geometry": {
"type": "geo_shape"
}
}
}
}
}
}
}
}
首先-这是正确的方式来Map?
第二,假设我想创建一个查询,从弹性的所有文档中提取交叉的“区域”。我使用这个查询:
{
"query": {
"geo_shape": {
"region.features.geometry": {
"relation": "intersects",
"shape": {
"type": "polygon",
"coordinates": [[[10.526270711323841,10.444489244321758],
[11.925063668547947,10.371171909552444],
[11.070002142972083,9.364612094349482],
[10.526270711323841,10.444489244321758]
]]
}
}
}
}
}
我得到一个错误:
failed to find geo_shape field [region.features.geometry]
那么,如何存储FeatureCollection
类型的“规范化”GeoJSON并进行下降查询呢?
1条答案
按热度按时间bkkx9g8r1#
ES确实支持
GeometryCollections
,但需要一些预处理。使用最小可重复索引设置:
提取
features
以符合w/请注意,
regions.geometries
可以包含多个geojson特征,而不仅仅是多边形。之后,我们可以查询多边形的交集:
注意:你的索引多边形在Anchorage,AK,而查询中的多边形在尼日利亚东部。两者不会重叠:)
所以我上面的查询测试了Eagle River周围的紫色多边形: