前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ES常用操作--postman实现

ES常用操作--postman实现

作者头像
伍六七AI编程
发布2019-10-08 18:04:01
1.2K0
发布2019-10-08 18:04:01
举报
文章被收录于专栏:preparedprepared

ES常用操作--postman实现

es-Range Aggregation(范围聚合)

A multi-bucket value source based aggregation that enables the user to define a set of ranges-每个代表一个bucket。

在聚合过程中,从每个文件中提取的值将根据每个存储区范围进行检查,并对相关/匹配文档进行“bucket”,值得注意的是,注意,此聚合包含了from值,不包括每个范围的to的值

例子:

代码语言:javascript
复制
{
    "aggs" : {
        "price_ranges" : {
            "range" : {
                "field" : "price",
                "ranges" : [
                    { "to" : 50 },
                    { "from" : 50, "to" : 100 },
                    { "from" : 100 }
                ]
            }
        }
    }
}

响应结果:

代码语言:javascript
复制
{
    ...
 
    "aggregations": {
        "price_ranges" : {
            "buckets": [
                {
                    "to": 50,
                    "doc_count": 2
                },
                {
                    "from": 50,
                    "to": 100,
                    "doc_count": 4
                },
                {
                    "from": 100,
                    "doc_count": 4
                }
            ]
        }
    }
}

http://cwiki.apachecn.org/pag...

es建表

发送 put 请求

代码语言:javascript
复制
192.168.2.11:9200/IndexName

文本raw,数据为json格式

代码语言:javascript
复制
{
    "settings":{
        "number_of_shards":5,
        "number_of_replicas":1
    },
    "mappings":{
        "TypeName":{
            "dynamic":"strict",
            "properties":{
                "tableId":{"type":"string","store":"yes","index":"not_analyzed"},
                "title":{"type":"string","store":"yes","index":"analyzed","analyzer": "ik_max_word","search_analyzer": "ik_max_word"},
                "author":{"type":"string","store":"yes","index":"analyzed","analyzer": "ik_max_word","search_analyzer": "ik_max_word"},
                "summary":{"type":"string","store":"yes","index":"analyzed","analyzer": "ik_max_word","search_analyzer": "ik_max_word"},
                "contextSrc":{"type":"string","store":"yes","index":"not_analyzed","ignore_above": 100},
                "context":{"type":"string","store":"yes","index":"analyzed","analyzer": "ik_max_word","search_analyzer": "ik_max_word"},
                "keywords":{"type":"string","store":"yes","index":"analyzed","analyzer": "ik_max_word","search_analyzer": "ik_max_word"},
                "publishDate":{"type":"string","store":"yes","index":"not_analyzed"},
                "createTime":{"type":"string","store":"yes","index":"not_analyzed"},
                "modifyTime":{"type":"string","store":"yes","index":"not_analyzed"},
                "deleteTime":{"type":"string","store":"yes","index":"not_analyzed"},
                "url":{"type":"string","store":"yes","index":"not_analyzed"},
                "isDeleted":{"type":"string","store":"yes","index":"not_analyzed"}
            }
        }
    }
}

举例说明:

PUT http://ip:port/indexname/

代码语言:javascript
复制
{
    "settings":{
        "index":{
            "number_of_shards":5,
            "number_of_replicas":1
      }
        
    },
    "mappings":{
        "koms_aibox_currentgpsclose":{
            "properties":{
                "id":{"type":"keyword"},
                "transit_time":{"type":"keyword"},
                "alerm_state":{"type":"keyword"},
                "gps_time":{"type":"keyword"},
                "travel_time":{"type":"keyword"},
                "abnormal_coos":{"type":"keyword"},
                "date":{"type":"keyword"}
            }
        }
    }
}
图片描述
图片描述

注:

https://ask.hellobi.com/blog/...

http://www.cnblogs.com/sunny3...

https://blog.csdn.net/liuxiao...

es批量添加数据

示例

代码语言:javascript
复制
XPOST ip:port/indexname/typename/_bulk

格式说明

代码语言:javascript
复制
post ip:port索引/类型/_bulk

使用 POSTMAN 批量导出数据

在这里插入图片描述
在这里插入图片描述

es添加数据

代码语言:javascript
复制
POST http://ip:port/indexname/typename/3

说明:

3 是 id,可写可不写,不写自动生产

代码语言:javascript
复制
{
    "tgs_id":"433100100153",
    "field1":"value1",
    "field2":"value2",
    "field3":"value3",
    "field4":"value4"
}

pass_car

代码语言:javascript
复制
{
        "tgs_id":"433100100153",
        "field1":"value1",
        "field2":"value2",
        "field3":"value3",
        "field4":"value4"
        "time_frame": "9"
}
图片描述
图片描述

https://blog.csdn.net/hzrandd...

https://blog.csdn.net/xsdxs/a...

es 查询数据

XGET http://ip:port/indexname/typename/_search?scroll=10m

BODY

代码语言:javascript
复制
{
    "query": { "match_all": {}},
    "size":  1000
}

其他基础操作

查询所有索引

代码语言:javascript
复制
GET http://ip:port/_cat/indices?v

删除索引

代码语言:javascript
复制
DELETE /my_index

删除多个索引

代码语言:javascript
复制
DELETE /index_one,index_two
DELETE /index_*

删除全部索引

代码语言:javascript
复制
DELETE /_all
DELETE /*
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • ES常用操作--postman实现
    • es-Range Aggregation(范围聚合)
      • es建表
        • 举例说明:
      • es批量添加数据
        • es添加数据
          • es 查询数据
            • 其他基础操作
              • 查询所有索引
              • 删除索引
              • 删除多个索引
              • 删除全部索引
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档