ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## index索引 ``` PUT /customer/_doc/1 { "name": "John Doe" } ``` ## bulk ``` POST bank/_bulk?pretty&refresh { "account_number": 0, "balance": 16623, "firstname": "Bradshaw", "lastname": "Mckenzie", "age": 29, "gender": "F", "address": "244 Columbus Place", "employer": "Euron", "email": "bradshawmckenzie@euron.com", "city": "Hobucken", "state": "CO" } ``` ## match\_all ``` { "query": { "match_all": {} }, //match_all搜索全部 "sort": [ { "account_number": "asc" } ] } GET /bank/_search { "query": { "match_all": {} }, "sort": [ { "account_number": "asc" } ], "from": 10, "size": 10 } ``` ## match ``` GET /bank/_search { "query": { "match": { "address": "mill lane" } } } ``` match\_prase ``` GET /bank/_search { "query": { "match_phrase": { "address": "mill lane" } } } ``` bool ``` GET /bank/_search { "query": { "bool": { "must": [ { "match": { "age": "40" } } ], "must_not": [ { "match": { "state": "ID" } } ] } } } GET /bank/_search { "query": { "bool": { "must": { "match_all": {} }, "filter": { "range": { "balance": { "gte": 20000, "lte": 30000 } } } } } } ``` ``` GET /bank/_search { "size": 0, "aggs": { "group_by_state": { "terms": { "field": "state.keyword" } } } } 使用terms汇总将bank索引中的所有帐户按状态分组,并按降序返回帐户数量最多的十个州 ``` ``` GET /bank/_search { "size": 0, "aggs": { "group_by_state": { "terms": { "field": "state.keyword", "order": { "average_balance": "desc" } }, "aggs": { "average_balance": { "avg": { "field": "balance" } } } } } } ```