基于ES版本6.x
索引信息
查询映射结构
GET /index_name
GET t_binding/_search { "from": 0, "size": 10, "query": { "bool": { "must": [ { "terms": { "FIELD": [ "VALUE1", "VALUE2" ] } }, { "term": { "FIELD": { "value": "VALUE" } } }, { "range": { "FIELD": { "gte": 10, "lte": 20 } } }, { "wildcard": { "FIELD": { "value": "VALUE" } } } ], "should": [ {} ] } } }
GET t_binding/_search { "query": { "bool": { "must": [ { "term": { "bind_no_type": { "value": "AXE" } } } ], "filter": { "term": { "bind_id": "VALUE" } } } } }
GET t_private_number_distribution/_search { "query": { "bool": { "filter": { "script": { "script": { "source": "doc['e_no_enable'].length + doc['e_no_disable'].length!=9000" } } } } } }
GET t_binding/_search?size=0 { "query": { "bool": { "must": [ { "term": { "bind_no_type": { "value": "AXE" } } } ] } }, "aggs": { "group_by_sno": { "terms": { "field": "s_no", "size": 10 }, "sub-aggs": { "NAME": { "AGG_TYPE": {} } } } } }
{ "took" : 7, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : 22, "max_score" : 0.0, "hits" : [ ] }, "aggregations" : { "group_by_sno" : { "doc_count_error_upper_bound" : 0, "sum_other_doc_count" : 0, "buckets" : [ { "key" : "17801476624", "doc_count" : 5 }, { "key" : "18413271317", "doc_count" : 4 }, { "key" : "41000000008", "doc_count" : 4 }, { "key" : "18430870106", "doc_count" : 2 }, { "key" : "18430870107", "doc_count" : 2 }, { "key" : "12345670013", "doc_count" : 1 }, { "key" : "12345670516", "doc_count" : 1 }, { "key" : "17897515942", "doc_count" : 1 }, { "key" : "41000000002", "doc_count" : 1 }, { "key" : "41000000007", "doc_count" : 1 } ] } } }
GET t_binding/_search?size=0 { "query": { "bool": { "must": [ { "term": { "bind_no_type": { "value": "AXE" } } } ] } }, "aggs": { "sum": { "sum": { "field": "" } }, "min":{ "min": { "field": "" } }, "max":{ "max": { "field": "" } }, "avg":{ "avg": { "field": "" } }, "count":{ "value_count": { "field": "" } } } }
GET t_binding/_search?size=0 { "query": { "bool": { "must": [ { "term": { "bind_no_type": { "value": "AXE" } } } ] } }, "aggs": { "date": { "date_histogram": { "field": "create_tm", "interval": "month" } } } }
{ "took" : 4, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : 22, "max_score" : 0.0, "hits" : [ ] }, "aggregations" : { "date" : { "buckets" : [ { "key_as_string" : "2022-05-01T00:00:00.000Z", "key" : 1651363200000, "doc_count" : 1 }, { "key_as_string" : "2022-06-01T00:00:00.000Z", "key" : 1654041600000, "doc_count" : 21 } ] } } }
GET _cat/indices
green open t_sms_billing_detail_2022-09-13 ROno8AiySFWW_-iu-gHPSA 2 1 117158 0 82.4mb 41.2mb green open t_call_recoding_2021-12-08 2byyq6GrRpCP_ADY9-RRLQ 10 1 62217 58 69.8mb 34.9mb green open t_call_recoding_2022-08-06 f46geckQRVavtY4-43BqNA 2 1 126996 16 140.1mb 70mb green open t_call_recoding_2021-08-09 -M6E9CD1TmiJZDvw-BP2eA 5 1 42 7 599.4kb 299.7kb green open t_call_billing_detail_2022-07-05 eEX1pzvSQwCp6XJOyGfiSg 2 1 323633 0 336.2mb 168.1mb green open t_call_log_2022-01-19 RLvBZb5PQEuSP4KktGXH7A 10 1 703578 0 382.6mb 191.2mb green open t_binding_log_2022-01-08 ZaqlEgipRdmBY69V8mBrlg 10 1 976035 0 613.2mb 306.5mb green open t_binding_log_2021-06-23 jwgX660ZQGqT3tRQzRzF2Q 5 1 673 0 1.1mb 567.8kb green open t_call_log_2022-05-19 jyXw1bo_QK2EoYns4xI3KA 2 1 436463 0 216mb 108.5mb
# t_binding_log_template是模版名称,t_binding_log*是索引的模版,t_binding_log是所有索引的别名,_doc是索引的type PUT _template/t_binding_log_template { "index_patterns": [ "t_binding_log*" ], "aliases": { "t_binding_log": {} }, "settings": { "number_of_shards": 10, "number_of_replicas": 1, "refresh_interval": "60s" }, "mappings": { "_doc": { "properties": { "log_source": { "type": "keyword" }, "log_type": { "type": "keyword" }, "fk_bind_id": { "type": "keyword" }, "fk_enterprise_id": { "type": "keyword" }, "fk_account_id": { "type": "keyword" }, "fk_supplier_id":{ "type":"keyword" }, "fk_account_name":{ "type":"keyword" }, "fk_supplier_name":{ "type":"keyword" }, "fk_enterprise_name":{ "type":"keyword" }, "fk_pool_sn": { "type": "keyword" }, "a_no": { "type": "keyword" }, "s_no": { "type": "keyword" }, "s_no_tag": { "type": "keyword" }, "b_no": { "type": "keyword" }, "e_no": { "type": "keyword" }, "bind_no_type": { "type": "keyword" }, "bind_tm": { "type": "date", "format": "date_optional_time||epoch_millis" }, "unbind_tm": { "type": "date", "format": "date_optional_time||epoch_millis" }, "expired_tm": { "type": "date", "format": "date_optional_time||epoch_millis" }, "b_expired_tm": { "type": "date", "format": "date_optional_time||epoch_millis" }, "need_record": { "type": "integer" }, "call_display_type": { "type": "integer" }, "before_connection_audio": { "type": "keyword" }, "after_connection_audio": { "type": "keyword" }, "user_data": { "type": "keyword" }, "create_tm": { "type": "date", "format": "date_optional_time||epoch_millis" }, "update_tm": { "type": "date", "format": "date_optional_time||epoch_millis" }, "creator": { "type": "keyword" }, "updater": { "type": "keyword" }, "status_code": { "type": "integer" }, "fail_cause": { "type": "text" } } } } }
PUT t_binding { "mappings": { "_doc": { "properties": { "_class": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "a_no": { "type": "keyword" }, "after_connection_audio": { "type": "keyword" }, "b_expired_tm": { "type": "date", "format": "date_optional_time" }, "b_no": { "type": "keyword" }, "before_connection_audio": { "type": "keyword" }, "bind_id": { "type": "keyword" }, "bind_no_type": { "type": "keyword" }, "bind_tm": { "type": "date", "format": "date_optional_time" }, "call_display_type": { "type": "integer" }, "create_tm": { "type": "date", "format": "date_optional_time" }, "creator": { "type": "keyword" }, "e_no": { "type": "keyword" }, "expired_tm": { "type": "date", "format": "date_optional_time" }, "fk_account_id": { "type": "keyword" }, "fk_account_name": { "type": "keyword" }, "fk_enterprise_id": { "type": "keyword" }, "fk_enterprise_name": { "type": "keyword" }, "fk_pool_sn": { "type": "keyword" }, "fk_supplier_id": { "type": "keyword" }, "fk_supplier_name": { "type": "keyword" }, "id": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "need_record": { "type": "integer" }, "s_no": { "type": "keyword" }, "s_no_tag": { "type": "keyword" }, "update_tm": { "type": "date", "format": "date_optional_time" }, "updater": { "type": "keyword" }, "user_data": { "type": "keyword" }, "version": { "type": "long" } } } }, "settings": { "index": { "refresh_interval": "2s", "number_of_shards": "40", "number_of_replicas": "1" } } }
POST /_aliases { "actions":[ { "add":{ "index": ["index_name"], "alias": alias_name } } ] }
POST /t_region/_doc/_bulk { "index":{} } {"province":"上海市","city":"市辖区","province_city":"/上海市/市辖区"} { "index":{} } {"province":"云南省","city":"临沧市","province_city":"/云南省/临沧市"} { "index":{} } {"province":"云南省","city":"丽江市","province_city":"/云南省/丽江市"}
POST index_name/_update_by_query?slices=auto&conflicts=proceed&wait_for_completion=false { "script": { "source": "ctx._source.likes++", "lang": "painless" }, "query": { "term": { "user": "kimchy" } } }
PUT index_name/_mapping/_doc { "properties": { "email": { "type": "keyword" } } }
PUT /index_name/_settings { "index" : { "number_of_replicas" : 2, "refresh_interval" : "1s" } }
POST /_reindex?wait_for_completion=false { "source": { "index": index_source_name, "size":5000 }, "dest": { "index": index_dest_name, "op_type": "create" }, "conflicts": "proceed" }
//多线程并发删除满足查询条件的数据 POST /index-name/_delete_by_query?slices=auto&conflicts=proceed&wait_for_completion=false { "query": { "bool": {} } }
DELETE index_name