ES經常使用操做--postman實現

ES經常使用操做--postman實現

es-Range Aggregation(範圍聚合)

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

在聚合過程當中,從每一個文件中提取的值將根據每一個存儲區範圍進行檢查,並對相關/匹配文檔進行「bucket」,值得注意的是,注意,此聚合包含了from值,不包括每一個範圍的to的值apache

例子:json

{
    "aggs" : {
        "price_ranges" : {
            "range" : {
                "field" : "price",
                "ranges" : [
                    { "to" : 50 },
                    { "from" : 50, "to" : 100 },
                    { "from" : 100 }
                ]
            }
        }
    }
}

響應結果:app

{
    ...
 
    "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...elasticsearch

es建表

發送 put 請求ide

192.168.2.11:9200/IndexName

文本raw,數據爲json格式post

{
    "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/ui

{
    "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"}
            }
        }
    }
}

圖片描述

注:url

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

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

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

es批量添加數據

示例

XPOST ip:port/indexname/typename/_bulk

格式說明

post ip:port索引/類型/_bulk

使用 POSTMAN 批量導出數據

在這裏插入圖片描述

es添加數據

POST http://ip:port/indexname/typename/3

說明:

3 是 id,可寫可不寫,不寫自動生產

{
    "tgs_id":"433100100153",
    "field1":"value1",
    "field2":"value2",
    "field3":"value3",
    "field4":"value4"
}

pass_car

{
        "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

{
    "query": { "match_all": {}},
    "size":  1000
}

其餘基礎操做

查詢全部索引

GET http://ip:port/_cat/indices?v

刪除索引

DELETE /my_index

刪除多個索引

DELETE /index_one,index_two
DELETE /index_*

刪除所有索引

DELETE /_all
DELETE /*

https://www.elastic.co/guide/...

相關文章
相關標籤/搜索