Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to view, delete, and create indexes in ElasticSearch

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the knowledge of "how to view, delete and create an index in ElasticSearch". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Note: {{es-host}} is a local variable configured in postman. The value of the variable is 192.168.100.102, which is one of the nodes in the es cluster.

1. Check the health status of the cluster GET http://{{es-host}}/_cat/health?vepoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent1565356074 13:07:54 elasticsearch green 3 3 10 500 00-100.0% 2. View the index list GET http://{{es-host}}/_cat/indices?vhealth status index uuid pri rep docs.count docs.deleted store.size pri.store.sizegreen open ecommerce YO4DgZuSTe23piO6hjF--w 5 1 3 0 34.2kb 17.1kb3, View the list of nodes GET http://{{es-host}}/_cat/nodes?vip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name192.168.100.102 35 95 0 0.04 0.04 0.05 mdi-es-node3192.168.100.102 23 95 0 0.04 0 .04 0.05 mdi * es-node1192.168.100.102 35 95 0 0.04 0.04 0.05 mdi-es-node24, Create index PUT http://{{es-host}}/test-index?pretty5, delete index DELETE http://{{es-host}}/test-index6, add goods and create inde and type

(1),

PUT http://{{es-host}}/ecommerce/produce/1{ "name": "gaolujie yagao", "desc": "gaoxiao meibai", "price": 30, "producer": "gaolujie producer", "tags": ["meibai", "fangzhu"]} result: {"_ index": "ecommerce", "_ type": "produce" "_ id": "1", "_ version": 10, "result": "created", "_ shards": {"total": 2, "successful": 2, "failed": 0}, "created": true}

(2),

PUT http://{{es-host}}/ecommerce/produce/2{ "name": "jiajieshi yagao", "desc": "youxiao fangzhu", "price": 25, "producer": "jiajieshi producer", "tags": ["fangzhu"]}

(3),

PUT http://{{es-host}}/ecommerce/produce/3{ "name": "zhonghua yagao", "desc": "caoben zhiwu", "price": 40, "producer": "zhonghua producer" "tags": ["qingxin"]} 7. Query GET http://{{es-host}}/ecommerce/produce/1 query results according to Id: {"_ index": "ecommerce", "_ type": "produce", "_ id": "1", "_ version": 7, "found": true "_ source": {"name": "gaolujie yagao", "desc": "gaoxiao meibai", "price": 30, "producer": "gaolujie producer", "tags": ["meibai" "fangzhu"]} 8. Modify a single attribute POST http://{{es-host}}/ecommerce/produce/1/_update{ "doc": {"price": 30}} 9, overwrite and modify PUT http://{{es-host}}/ecommerce/produce/1{ "name": "gaolujie yagao1" "desc": "gaoxiao meibai", "price": 30, "producer": "gaolujie producer", "tags": ["meibai", "fangzhu"]} result: {"_ index": "ecommerce", "_ type": "produce", "_ id": "1", "_ version": 8, "result": "updated" "_ shards": {"total": 2, "successful": 2, "failed": 0}, "created": false} 10. Delete data according to id DELETE http://{{es-host}}/ecommerce/produce/1 result: {"found": true, "_ index": "ecommerce", "_ type": "produce", "_ id": "1" "_ version": 9, "result": "deleted", "_ shards": {"total": 2, "successful": 2, "failed": 0}} "how to view, delete and create indexes in ElasticSearch" ends here. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report