GET bank/_mapping GET bank/_search GET bank/_search { "aggs": { "age_group": { "range": { "field": "age", "ranges": [ { "from": 20, "to": 29 }, { "from": 30, "to": 39 }, { "from": 40, "to": 49 } ] }, "aggs": { "gender_group": { "terms": { "field": "gender.keyword" }, "aggs": { "balance_avg": { "avg": { "field": "balance" } } } } } } }, "size": 0 } GET bank/_search { "aggs": { "state_group": { "terms": { "field": "state.keyword", "order": { "balance_avg": "asc" } }, "aggs": { "balance_avg": { "avg": { "field": "balance" } } } } }, "size": 0 } GET bank/_search { "aggs": { "state_group": { "terms": { "field": "state.keyword" }, "aggs": { "balance_avg": { "avg": { "field": "balance" } } } } }, "size": 0 } GET bank/_search { "aggs": { "state_group": { "terms": { "field": "state.keyword" } } }, "size": 0 } GET bank/_search { "query": { "bool": { "must": [ { "range": { "balance": { "gte": 20000, "lte": 30000 } } } ] } }, "sort": [ { "balance": { "order": "desc" } } ] } GET bank/_search { "query": { "range": { "balance": { "gte": 20000, "lte": 30000 } } }, "sort": [ { "balance": { "order": "desc" } } ] } GET bank/_search { "query": { "bool": { "must": [ { "match": { "age": 40 } } ], "must_not": [ { "match": { "state": "ID" } } ] } } } GET bank/_search { "query": { "bool": { "must_not": [ { "match": { "address": "mill" } }, { "match": { "address": "lane" } } ] } } } GET bank/_search { "query": { "bool": { "must": [ { "match": { "address": "mill" } }, { "match": { "address": "lane" } } ] } } } GET bank/_search { "query": { "match_phrase": { "address": "mill lane" } } } GET bank/_search { "query": { "bool": { "should": [ { "match": { "address": "mile" } }, { "match": { "address": "lane" } } ] } } } GET bank/_search { "query": { "match": { "address": "mill lane" } } } GET bank/_search { "query": { "match": { "address": "mill" } } } GET bank/_search?q=account_number:20 GET bank/_search { "query": { "match": { "account_number": "20" } } } GET bank/_search { "query": { "bool": { "must": [ { "match": { "account_number": 20 } } ] } } } GET /bank/_search { "query": { "match_all": {} }, "_source": ["account_number","balance"] } GET bank/_search { "query": { "match_all": {} }, "sort": [ { "balance": { "order": "desc" } } ], "size": 10 } POST bank/_update/1 { "script":"ctx._source.age+=5" } GET bank/_doc/1 POST my_index/_doc { "productName":"雪花啤酒100L" } GET my_index/_search { "query": { "match": { "productName": "xh" } } } PUT /my_index/_mapping { "properties":{ "productName":{ "type":"text", "analyzer":"ik_pinyin_analyzer", "search_analyzer":"ik_pingying_smark" } } } PUT my_index { "settings": { "analysis": { "analyzer": { "ik_pinyin_analyzer": { "type": "custom", "tokenizer": "ik_smart", "filter": [ "pinyin_max_word_filter" ] }, "ik_pingying_smark": { "type": "custom", "tokenizer": "ik_smart", "filter": [ "pinyin_smark_word_filter" ] } }, "filter": { "pinyin_max_word_filter": { "type": "pinyin", "keep_full_pinyin": "true", "keep_separate_first_letter": "true", "keep_joined_full_pinyin": true }, "pinyin_smark_word_filter": { "type": "pinyin", "keep_separate_first_letter": "false", "keep_first_letter": "false" } } } } } POST /_analyze { "analyzer": "pinyin", "text":"我是中国人" } POST /_analyze { "analyzer": "simple", "text": "决战到天亮" } POST /_analyze { "analyzer": "ik_smart", "text": "我是中国人" } POST /_analyze { "analyzer": "ik_max_word", "text": "太白" } POST bank/_search { "aggs": { "group_by_age": { "range": { "field": "age", "ranges": [ { "from": 20, "to": 30 }, { "from": 30, "to": 40 }, { "from": 40, "to": 50 } ] } } }, "size": 0 } POST bank/_search { "aggs": { "taibai": { "terms": { "field": "age" }, "aggs": { "count": { "top_hits": { "size": 3 } } } } }, "size": 0 } POST bank/_search { "aggs": { "taibai": { "terms": { "field": "age" } } }, "size": 0 } POST bank/_search { "aggs": { "taibai": { "value_count": { "field": "age" } } }, "size": 0 } POST bank/_search { "aggs": { "taibai": { "extended_stats": { "field": "age" } } }, "size": 0 } POST bank/_search { "aggs": { "taibai": { "cardinality": { "field": "age" } } }, "size": 0 } POST bank/_search { "aggs": { "taibai": { "avg": { "script": { "source": "doc.age.value" } } } }, "size": 0 } POST bank/_search { "aggs":{ "taibai":{ "avg":{ "field": "age" } } }, "size":0 } GET taibai/_search { "query": { "bool": { "must": { "term": { "sex": "男" } }, "must_not": { "term": { "age": "29" } }, "should":[ { "term":{ "sex": "男" } }, {"term":{ "id": "1003" } } ] } } } GET taibai/_search { "query": { "match": { "name": "三" } } } GET taibai/_search { "query": { "range": { "age": { "gte": 20, "lte": 30 } } } } GET taibai/_search { "query": { "exists": { "field": "age" } } } GET taibai/_search { "query": { "term": { "name.keyword": "张三" } } } POST /_analyze { "analyzer":"standard", "text":"决战到天亮" } POST /_analyze { "analyzer":"ik_max_word", "text":"决战到天亮" } POST /_analyze { "analyzer": "standard", "text": "张三" } GET taibai/_mapping GET taibai/_search { "query": { "term": { "name": "张三" } } } GET taibai/_search GET /bank/_search { "size": 2, "from": 0, "sort": [ { "_id": { "order": "asc" } } ], "search_after":[ 1 ] } //浅分页 GET bank/_search { "size": 20, "from": 0, "sort": [ { "_id": { "order": "desc" } } ] } GET /bank/_search?scroll=5m { "size": 20, "from": 0, "sort": [ { "_id": { "order": "desc" } } ] } GET _search/scroll { "scroll_id": "FGluY2x1ZGVfY29udGV4dF91dWlkDXF1ZXJ5QW5kRmV0Y2gBFkM2RkJhMEFGU3g2OWZLQ0trNEpzcVEAAAAAAAAIyBZ4UEV6VFpWTlFoZXNhMkRQNHdZZVh3", "scroll":"5m" } DELETE _search/scroll/FGluY2x1ZGVfY29udGV4dF91dWlkDXF1ZXJ5QW5kRmV0Y2gBFkM2RkJhMEFGU3g2OWZLQ0trNEpzcVEAAAAAAAAIyBZ4UEV6VFpWTlFoZXNhMkRQNHdZZVh3 DELETE _search/scroll/_all GET bank/_search { "query": { "match_all": {} }, "sort": [ { "_id": { "order": "asc" } } ], "size": 4, "from": 0 } POST _bulk { "create" :{ "_index" : "taibai", "_id" : "101" } } {"id":101,"name":"name1","age": 20,"sex": "男"} { "create" : { "_index" : "taibai", "_id" : "401" }} {"id":401,"name":"name1","age": 20,"sex": "男"} POST _bulk { "update" :{ "_index" : "taibai", "_id" : "101" } } {"doc": {"id":101,"name":"name101","age": 201,"sex": "男101"}} { "update" : { "_index" : "taibai", "_id" : "401" }} {"doc": {"id":401,"name":"name401","age": 20401,"sex": "男401"}} POST _bulk { "delete":{ "_index" : "taibai", "_id":"101" }} { "delete": { "_index" : "taibai", "_id":"401" }} GET taibai/_search GET /bank/_mget { "ids":[ "1","40" ] } GET bank/_source/40?_source=age,email GET bank/_doc/40?_source=id,name GET bank/_search?q=age:23 GET bank/_search { "query": { "match_all": {} }, "size": 1000, "from": 0 } GET taibai/_search POST taibai/_doc { "id":1001, "name" : "张三", "age" : 22, "sex" : "男" } GET kuangshen/user/_search { "query":{ "match": { "name": "狂神" } }, "_source":["name","desc"] } POST taibai/_doc/1001 { "id":1002, "name":"太白" } GET taibai/_search PUT /taibai { "settings": { "number_of_replicas": 0, "number_of_shards": 1 } } DELETE taibai POST taibai/_doc { "id":1001, "name":"taibai" } PUT taibai/_doc/1002 { "id":1002, "name":"taibai", "age":21, "sex":"哈哈" } POST /taibai/_update/1002 { "doc": { "age":21 } } GET /taibai/_doc/1002 DELETE taibai/_doc/9gU0l3sBa2-WIiyKQyQG
完