ES7.6.2 使用kibana操作索引库

    技术2025-04-12  15

    1,插入索引 PUT /索引/~类型名~/文档id/ {请求体} PUT /test1/type1/1 { "name": "梁振周", "age": 27 } 2,创建索引规则 PUT /test2/ { "mappings": { "properties": { "name" :{ "type": "text" }, "age" :{ "type": "long" }, "birthday" :{ "type": "date" } } } } #####使用默认类型 PUT /tset3/_doc/1 { "name": "乔哈哈", "age": 18, "birth": "2000-01-01" } 3,GET _cat/health 查看监看信息 GET _cat/indices?v 查看全部索引库 health status index uuid pri rep docs.count docs.deleted store.size pri.store.size yellow open test2 h98thw7QRLW9034-Bsj5Zw 1 1 0 0 283b 283b yellow open bigdata bw4xnDp5QzOU_wevRGuzeg 1 1 0 0 283b 283b green open .kibana_task_manager_1 udZtTM7tQeOzhyLwqLVSoA 1 0 2 0 32kb 32kb green open .apm-agent-configuration fTgzE0yNQ_WbzfUFKX-L4w 1 0 0 0 283b 283b yellow open tset3 kq1st3cTRK6RHqhqFshmyQ 1 1 1 0 7.7kb 7.7kb green open .kibana_1 o_a5xNggSDC3_XNcUEGmog 1 0 15 4 38.2kb 38.2kb 4,修改索引 a,使PUT PUT /tset3/_doc/1 { "name": "乔哈哈123", "age": 18, "birth": "2000-01-01" } { "_index" : "tset3", "_type" : "_doc", "_id" : "1", "_version" : 2, (版本加1) "result" : "updated",(之前是create) "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 1, "_primary_term" : 1 } b,使用post POST /tset3/_doc/1/_update { "doc": { "name": "哈哈乔post修改" } } { "_index" : "tset3", "_type" : "_doc", "_id" : "1", "_version" : 3, "result" : "updated", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 2, "_primary_term" : 1 } 5,删除索引 DELETE test1 6.搜索 PUT /liangzhenzhou/user/1 { "name": "梁振周", "age": 28, "desc": "百度一下,你就知道,我是谁,我在哪", "tages": ["喜欢音乐","游戏","技术宅"] } PUT /liangzhenzhou/user/2 { "name": "张三", "age": 28, "desc": "百度一下,你就知道,我是谁,我在哪", "tages": ["吸烟","喝酒","烫头"] } PUT /liangzhenzhou/user/5 { "name": "乔哈哈", "age": 18, "desc": "百度一下,你就知道,我是谁,我在哪", "tages": ["学习","吃美食","旅游"] } 查询全部 GET liangzhenzhou/user/_search a.简单条件查询 GET liangzhenzhou/user/_search?q=name:梁振周 b,精确查询 term查询是直接通过倒排索引指定的词条进行精确的查找。 关于分词: term,直接查询精确的 match,会使用分词器解析!(先分析文档,然后再通过分析的文档进行查询!) 两个类型: text类型:拆分查询 keyword类型:不拆分查询 匹配,按条件匹配,精准匹配,区间范围匹配,匹配字段过滤,多条件匹配,高亮查询 GET liangzhenzhou/user/_search { "query": { "bool": { "must": [ { "match": { "name": "梁振周" } } ], "filter": [ { "range": { "age": { "gt": 10 } } } ] } } }

     

    Processed: 0.014, SQL: 9