温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

ElasticSearch怎么查看、删除以及创建索引

发布时间:2021-09-07 09:16:32 来源:亿速云 阅读:198 作者:chen 栏目:大数据

本篇内容介绍了“ElasticSearch怎么查看、删除以及创建索引”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

说明:{{es-host}} 是在postman配置的一个本地变量 ,变量值是 192.168.100.102:9200 ,也就是es集群的其中一个节点

ElasticSearch怎么查看、删除以及创建索引

1、查看集群健康状况

GET http://{{es-host}}/_cat/health?v
epoch      timestamp cluster       status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1565356074 13:07:54  elasticsearch green           3         3     10   5    0    0        0             0                  -                100.0%

2、查看索引列表

GET http://{{es-host}}/_cat/indices?v
health status index     uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   ecommerce YO4DgZuSTe23piO6hjF--w   5   1          3            0     34.2kb         17.1kb

3、查看节点列表

GET http://{{es-host}}/_cat/nodes?v
ip              heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.100.102           35          95   0    0.04    0.04     0.05 mdi       -      es-node3
192.168.100.102           23          95   0    0.04    0.04     0.05 mdi       *      es-node1
192.168.100.102           35          95   0    0.04    0.04     0.05 mdi       -      es-node2

4、创建索引

PUT http://{{es-host}}/test-index?pretty

5、删除索引

DELETE http://{{es-host}}/test-index

6、添加商品同时创建inde和type

(1)、

PUT http://{{es-host}}/ecommerce/produce/1
{
	"name":"gaolujie yagao",
	"desc":"gaoxiao meibai",
	"price":30,
	"producer":"gaolujie producer",
	"tags":[
		"meibai","fangzhu"	
	]
}
结果:
{
    "_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、根据Id查询

GET http://{{es-host}}/ecommerce/produce/1

查询结果:
{
	"_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、修改单个属性

POST http://{{es-host}}/ecommerce/produce/1/_update
{
	"doc":{
		"price":30
	}
}

9、覆盖修改

PUT http://{{es-host}}/ecommerce/produce/1
{
	"name":"gaolujie yagao1",
	"desc":"gaoxiao meibai",
	"price":30,
	"producer":"gaolujie producer",
	"tags":[
		"meibai","fangzhu"	
	]
}
结果:
{
    "_index": "ecommerce",
    "_type": "produce",
    "_id": "1",
    "_version": 8,
    "result": "updated",
    "_shards": {
        "total": 2,
        "successful": 2,
        "failed": 0
    },
    "created": false
}

10、根据id删除数据

DELETE http://{{es-host}}/ecommerce/produce/1
结果:
{
    "found": true,
    "_index": "ecommerce",
    "_type": "produce",
    "_id": "1",
    "_version": 9,
    "result": "deleted",
    "_shards": {
        "total": 2,
        "successful": 2,
        "failed": 0
    }
}

“ElasticSearch怎么查看、删除以及创建索引”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI