我想知道如果我在 opensearch 中以 geojson 格式存盤空間資料。并使用地理形狀查詢而不是為查詢提供geojson格式來查詢它我以WKT格式提供形狀,它會對查詢產生任何影響嗎?就像它會按預期作業還是會回傳錯誤的結果。
我已經使用一些示例資料進行了嘗試,它按預期作業,但仍希望確保它能夠完美作業或可能導致一些問題。
這是代碼:
PUT test-index
{
"mappings": {
"properties": {
"geometry": {
"type": "geo_shape",
"tree": "quadtree"
}
}
}
}
# Index some documents.
POST test-index/_doc/1
{
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
88.76953125,
39.095962936305476
],
[
83.49609375,
36.03133177633187
],
[
82.705078125,
32.47269502206151
],
[
91.40625,
29.611670115197377
],
[
95.712890625,
35.38904996691167
],
[
88.76953125,
39.095962936305476
]
]
]
}
}
POST test-index/_doc/2
{
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
106.875,
47.100044694025215
],
[
100.37109375,
44.465151013519616
],
[
105.99609375,
38.47939467327645
],
[
114.521484375,
42.94033923363181
],
[
112.236328125,
49.210420445650286
],
[
106.875,
47.100044694025215
]
]
]
}
}
# Query documents based on geometry, provided in geojson format.
GET test-index/_search
{
"query": {
"geo_shape": {
"geometry": {
"shape": {
"type": "Polygon",
"coordinates": [
[
[
99.140625,
36.03133177633187
],
[
91.93359375,
35.31736632923788
],
[
100.37109375,
33.284619968887675
],
[
106.61132812499999,
37.78808138412046
],
[
106.61132812499999,
39.57182223734374
],
[
99.140625,
36.03133177633187
]
]
]
},
"relation": "intersects"
}
}
}
}
# Query using WKT.
GET test-index/_search
{
"query": {
"geo_shape": {
"geometry": {
"shape": "POLYGON ((99.140625 36.03133177633187, 91.93359375 35.31736632923788, 100.37109375 33.284619968887675, 106.61132812499999 37.78808138412046, 106.61132812499999 39.57182223734374, 99.140625 36.03133177633187))",
"relation": "intersects"
}
}
}
}
以上這兩個查詢都回傳了相同的結果。
感謝您的評論和反饋:)
uj5u.com熱心網友回復:
無論您使用什么(GeoJson、WKT、Geohash 等),最后一切都被正確決議為實作介面的幾何圖形。org.elasticsearch.geo.Geometry
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/508509.html
上一篇:此錯誤的原因是什么以及如何解決?