# es 命令 **Repository Path**: meixl/es_command ## Basic Information - **Project Name**: es 命令 - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-04-03 - **Last Updated**: 2024-04-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 索引 ## 新建 ``` PUT /my_index { "mappings": { "properties":{ "id":{ "type":"long" }, "name":{ "type":"keyword" }, "age":{ "type":"integer" }, "size" : { "type":"double" }, "create_time" : { "type":"date", "format":"yyyy-MM-dd HH:mm:ss" } } } } ``` ## 删除 DELETE /my_index ## 看指定 GET /my_index ## 看所有 GET _cat/indices # 文档 ## 新增一个(没有就加,有就改) ``` POST /my_index/_doc/223 { "id":1, "name":"dafei", "age":18 } ``` ## 新增一个-不指定id(没有就加,有就改) ``` POST /my_index/_doc { "id":1024, "name":"dafei", "age":18, "create_time" : "2024-04-13 23:44:44" } ``` ## 删除一个 DELETE /my_index/_doc/223 ## 修改一个 ``` PUT /my_index/_doc/456878 { "id":456, "name":"lake", "create_time" : "2024-04-01 23:44:44" } ``` ## 查单个 GET /my_index/_doc/456878 ## 查所有(默认前10条) GET /my_index/_search ## 分页 ``` GET /my_index/_search { "from": 50, "size": 10, "query": { "match_all": {} } } ``` ## 数据总数 ``` GET /my_index/_count { "query": { "match_all": {} } } ``` # 搜索 ## 单个搜索 ``` GET /product/_search { "query": { "match":{ "title": "拯救者" } } } ``` ## 多个搜索 ``` GET /product/_search { "query": { "multi_match":{ "query":"防眩光护眼屏", "fields": ["title", "intro"] } } } ``` ## 高亮搜索 ``` GET /product/_search { "query": { "multi_match":{ "query":"蓝牙 指纹 双卡", "fields": ["title", "intro"], "analyzer": "ik_smart" } }, "from": 0, "size": 10, "highlight": { "fields": { "title": {"type": "plain"}, "intro": {"type": "plain"} }, "pre_tags": "", "post_tags": "" } } ``` ## 分词查看(中文) * 在 config/main.dic 中添加自定义分词即可 ``` GET /product/_analyze { "text":"梅孝亮是一个java程序员", "analyzer":"ik_smart" } ```