成都创新互联网站制作重庆分公司

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

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

成都创新互联是一家专注于成都做网站、网站设计与策划设计,肇庆网站建设哪家好?成都创新互联做网站,专注于网站建设十余年,网设计领域的专业建站公司;建站业务涵盖:肇庆等地区。肇庆做网站价格咨询:028-86922220

说明:{{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怎么查看、删除以及创建索引”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!


标题名称:ElasticSearch怎么查看、删除以及创建索引
网页链接:http://cxhlcq.com/article/gsidsp.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部