GET /_cat/health?v
GET /_cat/indices?v
PUT /test_index1
PUT /product { "settings" : { "number_of_shards" : 3, "number_of_replicas" : 1 } } POST /product/_mapping?pretty { "_source": {"enabled": true}, "dynamic": true, "properties" : { "imei" : {"type" : "text","analyzer" : "keyword","fielddata": true}, "ispid" : {"type":"integer","ignore_malformed": true}, "msisdn" : {"type" : "text","analyzer" : "keyword","fielddata": true}, "maddr_s" : {"type" : "text","analyzer" : "ik_max_word","norms" : false,"fields" : {"raw" : {"type" : "keyword","doc_values":true}}}, "maddr_p" : {"type" : "text","analyzer" : "ik_max_word","norms" : false,"fields" : {"raw" : {"type" : "keyword","doc_values":true}}}, "maddr_c" : {"type" : "text","analyzer" : "ik_max_word","norms" : false,"fields" : {"raw" : {"type" : "keyword","doc_values":true}}}, "netaddr_s" : {"type" : "text","analyzer" : "ik_max_word","norms" : false,"fields" : {"raw" : {"type" : "keyword","doc_values":true}}}, "netaddr_p" : {"type" : "text","analyzer" : "ik_max_word","norms" : false,"fields" : {"raw" : {"type" : "keyword","doc_values":true}}}, "netaddr_c" : {"type" : "text","analyzer" : "ik_max_word","norms" : false,"fields" : {"raw" : {"type" : "keyword","doc_values":true}}}, "seraddr_s" : {"type" : "text","analyzer" : "ik_max_word","norms" : false,"fields" : {"raw" : {"type" : "keyword","doc_values":true}}}, "seraddr_p" : {"type" : "text","analyzer" : "ik_max_word","norms" : false,"fields" : {"raw" : {"type" : "keyword","doc_values":true}}}, "seraddr_c" : {"type" : "text","analyzer" : "ik_max_word","norms" : false,"fields" : {"raw" : {"type" : "keyword","doc_values":true}}}, "uli" : {"type" : "text","analyzer" : "ik_max_word","norms" : false,"fields" : {"raw" : {"type" : "keyword","doc_values":true}}}, "x_sip" : {"type" : "ip"}, "x_dip" : {"type" : "ip"}, "i_sport" : {"type" : "keyword","doc_values":true}, "i_dport" : {"type" : "keyword","doc_values":true}, "guti" : {"type" : "keyword","doc_values":true}, "i_nsapi" : {"type" : "long","ignore_malformed": true}, "apn" : {"type" : "text", "analyzer" : "keyword"}, "rai" : {"type" : "text", "analyzer" : "keyword"}, "gsnu" : {"type" : "text", "analyzer" : "keyword"}, "teid" : {"type" : "text", "analyzer" : "keyword"}, "endtime" : {"type" : "long","ignore_malformed": true}, "id" : {"type" : "long"}, "i_type" : {"type" : "text","analyzer" : "keyword"}, "conndirect" : {"type" : "text", "analyzer" : "keyword"}, "protocoltype" : {"type" : "text" ,"analyzer" : "keyword"}, "i_trojan_type" : {"type" : "long","ignore_malformed": true}, "pguti":{"type" : "text" ,"analyzer" : "keyword"}, "sid":{"type" : "text" ,"analyzer" : "keyword"}, "x_imsi":{"type" : "text" ,"analyzer" : "keyword","fielddata": true}, "pteid":{"type" : "text" ,"analyzer" : "keyword"}, "flow":{"type" : "long","ignore_malformed": true}, "vpsfirm":{"type" : "text" ,"analyzer" : "keyword"}, "x_begintime":{"type" : "long","ignore_malformed": true}, "netaddr" : {"type" : "keyword","doc_values":true}, "seraddr" : {"type" : "keyword","doc_values":true}, "maddr" : {"type" : "keyword","doc_values":true}, "paddr_s" : {"type" : "text","analyzer" : "ik_max_word","norms" : false,"fields" : {"raw" : {"type" : "keyword","doc_values":true}}}, "paddr_p" : {"type" : "text","analyzer" : "ik_max_word","norms" : false,"fields" : {"raw" : {"type" : "keyword","doc_values":true}}}, "paddr_c" : {"type" : "text","analyzer" : "ik_max_word","norms" : false,"fields" : {"raw" : {"type" : "keyword","doc_values":true}}}, "paddr" : {"type" : "keyword","doc_values":true}, "sshclient" : {"type" : "keyword","doc_values":true}, "sshserver" : {"type" : "keyword","doc_values":true}, "sshver" : {"type" : "keyword","doc_values":true}, "b_firstpacket" : {"type" : "binary"}, "b_firstpacket1" : {"type" : "text", "analyzer" : "keyword"}, "appbigt" :{"type" : "integer"}, "appsubt" :{"type" : "integer"} } }
GET /posts/_search
DELETE /test_index
POST /student/_bulk { "index": { "_id": 1 }} { "name" : "liubei", "age" : 20 , "sex": "boy", "birth": "1996-01-02" , "about": "i like diaocan he girl" } { "index": { "_id": 2 }} { "name" : "guanyu", "age" : 21 , "sex": "boy", "birth": "1995-01-02" , "about": "i like diaocan" } { "index": { "_id": 3 }} { "name" : "zhangfei", "age" : 18 , "sex": "boy", "birth": "1998-01-02" , "about": "i like travel" } { "index": { "_id": 4 }} { "name" : "diaocan", "age" : 20 , "sex": "girl", "birth": "1996-01-02" , "about": "i like travel and sport" } { "index": { "_id": 5 }} { "name" : "panjinlian", "age" : 25 , "sex": "girl", "birth": "1991-01-02" , "about": "i like travel and wusong" } { "index": { "_id": 6 }} { "name" : "caocao", "age" : 30 , "sex": "boy", "birth": "1988-01-02" , "about": "i like xiaoqiao" } { "index": { "_id": 7 }} { "name" : "zhaoyun", "age" : 31 , "sex": "boy", "birth": "1997-01-02" , "about": "i like travel and music" } { "index": { "_id": 8 }} { "name" : "xiaoqiao", "age" : 18 , "sex": "girl", "birth": "1998-01-02" , "about": "i like caocao" } { "index": { "_id": 9 }} { "name" : "daqiao", "age" : 20 , "sex": "girl", "birth": "1996-01-02" , "about": "i like travel and history" }
GET /student/_search { "query": { "bool":{ "must":[ { "match": { "about": "travel" } }, { "term":{ "sex":"boy" } }, { "range":{ "age":{ "gt":16, "lte":25 } } }, { "exists":{ "field":"age" } } ] } }, "aggs": { "all_interests": { "terms": { "field": "age" } } } }
GET /student/_search {"query": { "wildcard":{ "name": "li" } } }
聚合查询: all_interests自己定义的聚合名称
GET /student/_search { "aggs": { "all_interests": { "terms": { "field": "age" } } } }
原文:https://www.cnblogs.com/chong-zuo3322/p/13441638.html