Amazon OpenSearch Serviceで空間検索をするメモ。
今回の空間検索は下記のようなbbox内にあるポイントデータを検索してみます。事前にQGISでデータを可視化し検索したい左上と右下の経緯度を準備します。
空間検索をする条件を指定し左上と右下の経緯度を入力します。
POST point_geo_sample/_search
{
"query":{
"bool": {
"must": {
"match_all": {}
},
"filter": {
"geo_shape": {
"geometry": {
"shape": {
"type": "envelope",
"coordinates" : [[139.7802, 35.6781], [139.7878, 35.6724]]
},
"relation": "within"
}
}
}
}
}
}
検索結果がQGISの可視化と一致しました!
{
"took" : 9,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 3,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "point_geo_sample",
"_type" : "_doc",
"_id" : "mdQ_54EBMGUV534vZahT",
"_score" : 1.0,
"_source" : {
"type" : "Feature",
"properties" : {
"full_id" : "n1892534950",
"name" : "セブン-イレブン",
"shop" : "convenience"
},
"geometry" : {
"type" : "Point",
"coordinates" : [
139.7819038,
35.675297
]
}
}
},
{
"_index" : "point_geo_sample",
"_type" : "_doc",
"_id" : "yNQ_54EBMGUV534vZa1Z",
"_score" : 1.0,
"_source" : {
"type" : "Feature",
"properties" : {
"full_id" : "n3758524951",
"name" : "セブン-イレブン",
"shop" : "convenience"
},
"geometry" : {
"type" : "Point",
"coordinates" : [
139.7859394,
35.6769875
]
}
}
},
{
"_index" : "point_geo_sample",
"_type" : "_doc",
"_id" : "KtQ_54EBMGUV534vZadN",
"_score" : 1.0,
"_source" : {
"type" : "Feature",
"properties" : {
"full_id" : "n1215847202",
"name" : "NATURAL LAWSON",
"shop" : "convenience"
},
"geometry" : {
"type" : "Point",
"coordinates" : [
139.781879,
35.6744447
]
}
}
}
]
}
}