zoukankan      html  css  js  c++  java
  • 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"
                        }
                    }
                }
            }
        }
    }  
  • 相关阅读:
    C#学习-多态
    C#学习-子类的初始化顺序
    C#学习-面向对象
    Python数据类型知识点全解
    python 复制图片到剪贴板
    pyperclip
    pyautogui
    多线程代码案例
    常用正则表达式最强整理(速查手册)
    python os
  • 原文地址:https://www.cnblogs.com/lilei2blog/p/7799421.html
Copyright © 2011-2022 走看看