elasticsearch地理空间操作简单操作
Posted 李雷
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了elasticsearch地理空间操作简单操作相关的知识,希望对你有一定的参考价值。
创建索引库
PUT http://localhost:9200/geo { "mappings": { "poi": { "properties": { "name": { "type": "string" }, "location": { "type": "geo_shape" } } } } }
录入数据
curl -POST http://localhost:9200/geo/poi { "name": "北京华通康源科技有限公司", "location": { "type": "point", "coordinates": [116.65032, 40.33047] } } curl -POST http://localhost:9200/geo/poi { "name": "北京城磊鑫伟业工贸有限公司", "location": { "type": "point", "coordinates": [117.08914, 40.59023] } } curl -POST http://localhost:9200/geo/poi { "name": "null", "location": { "type": "point", "coordinates": [115.69617, 39.97179] } }
范围查询
{ "query":{ "bool": { "must": { "match_all": {} }, "filter": { "geo_shape": { "location": { "shape": { "type": "envelope", "coordinates" : [[111.0, 29.0], [117.0, 40.0]] }, "relation": "within" } } } } } }
以上是关于elasticsearch地理空间操作简单操作的主要内容,如果未能解决你的问题,请参考以下文章