美文网首页
es kibana常用命令及空间类型操作

es kibana常用命令及空间类型操作

作者: reco171 | 来源:发表于2021-02-09 16:42 被阅读0次
    1. 在elasticsearch和kibana环境下,常用命令如下:

查看所有数据

GET _search
{
"query": {
"match_all": {}
}
}

查看所有索引

GET /_cat/indices?v

创建索引,并通过mappings-〉properties指定字段及类型

PUT /testidx
{
"mappings": {
"properties": {
"title":{"type":"text"},
"name":{"type":"text"},
"created":{
"type": "date"
}
}
}
}

向testidx索引插入数据

PUT /testidx/_doc/5
{
"name":"zhaogj",
"title":"enginner",
"created":"2021-01-01"
}

查询testidx索引下所有数据

GET /testidx/_search
{
"query": {
"match_all": {}
}
}

    1. 创建包含geo_point类型字段索引及查询过滤数据

创建索引,该索引包含geo_point类型字段

geo point

PUT /geopidx
{
"mappings": {
"properties": {
"location":{
"type": "geo_point"
}
}
}
}

向geopidx索引插入数据

PUT /geopidx/_doc/1
{
"text":"obj",
"location":{
"lat":41.12,
"lon":-71.34
}
}

向geopidx索引插入数据

PUT /geopidx/_doc/2
{
"text":"obj",
"location":{
"lat":43.12,
"lon":-71.34
}
}

向geopidx索引插入数据

PUT /geopidx/_doc/3
{
"text":"obj",
"location":{
"lat":40.12,
"lon":-71.34
}
}

查询testidx索引下所有数据

GET /geopidx/_search
{
"query": {
"match_all": {}
}
}

向geopidx索引插入数据

PUT /geopidx/_doc/4
{
"text":"geo point as an array",
"location":[-71.34,41.12]
}

通过geo_bounding_box查询过滤数据

GET /geopidx/_search
{
"query": {
"geo_bounding_box":{
"location":{
"top_left":{
"lat":42,
"lon":-72
},
"bottom_right":{
"lat":40,
"lon":-74
}
}
}
}
}
-3. 创建包含geo_shape类型索引及查询过滤数据

创建索引,该索引包含geo_shape类型字段

geo shape

PUT /geosidx
{
"mappings": {
"properties": {
"location":{
"type": "geo_shape"
}
}
}
}
GET /geosidx/_search
{
"query": {
"match_all": {}
}
}
POST /geosidx/_doc
{
"location":{
"type":"polygon",
"coordinates":[
[[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0],[100.0,0.0]]
]
}
}
POST /geosidx/_doc
{
"location":"POLYGON((103.0 3.0,104.0 3.0, 104.0 4.0, 103.0 4.0,103.0 3.0))"
}
POST /geosidx/_doc
{
"location":"POLYGON((105.0 5.0,106.0 5.0, 106.0 6.0, 105.0 6.0,105.0 5.0))"
}

通过filter-〉envelope查询过滤数据

GET /geosidx/_search
{
"query": {
"bool": {
"must":{
"match_all":{}
},

    "filter":{
      "geo_shape":{
        "location":{
          "shape":{
            "type":"envelope",
            "coordinates":[[101.0,7.0],[107.0,0.0]]
          },
          "relation":"within"
        }
      }
    }
  
}

}
}

通过filter-〉coordinates查询过滤数据

GET /geosidx/_search
{
"query": {
"bool": {
"must":{
"match_all":{}
},

    "filter":{
      "geo_shape":{
        "location":{
          "shape":{
            "type":"polygon",
            "coordinates":[
  [[99.0,-1.0],[104.0,-1.0],[104.0,7.0],[99.0,7.0],[99.0,-1.0]]
  ]
          },
          "relation":"within"
        }
      }
    }
  
}

}
}

通过filter-〉POLYGON查询过滤数据

GET /geosidx/_search
{
"query": {
"bool": {
"must":{
"match_all":{}
},

    "filter":{
      "geo_shape":{
        "location":{
          "shape":"POLYGON((104.0 0.0,106.0 0.0, 106.0 6.0, 104.0 6.0,104.0 0.0))",
          "relation":"within"
        }
      }
    }
  
}

}
}

参考:

  1. Elasticsearch简介与实战

相关文章

网友评论

      本文标题:es kibana常用命令及空间类型操作

      本文链接:https://www.haomeiwen.com/subject/qnlcxltx.html