elasticsearch 简单操作

版权声明: https://blog.csdn.net/Master_chaoAndQi/article/details/83930019

1 查询健康状态 

http://192.168.34.3:9200/_cluster/health?pretty
{
  "cluster_name" : "elasticsearch",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 10,
  "active_shards" : 10,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 10,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 50.0
}

 2  查看节点列表

http://192.168.34.3:9200/_cat/nodes?v

3 查看索引列表

http://192.168.34.3:9200/_cat/indices?v

4 新增索引

[root@demo /]# curl -XPUT '192.168.34.3:9200/img?pretty'
{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "img"
}
[root@demo /]# 

5 删除索引

[root@demo /]# curl -XDELETE '192.168.34.3:9200/img?pretty'
{
  "acknowledged" : true
}
[root@demo /]# 

6 添加数据 

curl -XPUT -H "Content-Type: application/json" 'http://192.168.34.3:9200/test/demo/1?pretty' -d '
{
	
"titleName":"明星壁纸",
"titleUrl":"http://www.5442.com/mingxing/index.html",
"flag":"2",
"startPage":"157",
"endPage":"158"
}

7 查询数据  查询 test索引库下 类型为demo id 为1的数据(由于编码不统一出现乱码)

[root@demo 0]# curl -XGET '192.168.34.3:9200/test/demo/1'
{"_index":"test","_type":"demo","_id":"1","_version":2,"found":true,"_source":{

"titleName":"骀澹绾?,
"titleUrl":"http://www.5442.com/mingxing/index.html",
"flag":"2",
"startPage":"157",
"endPage":"158",
"name":"寮犱?"
}

8 搜索 查询索引库为test 条件字段titleName 模糊匹配明的信息

curl -XGET 'http://192.168.34.3:9200/test/_search?q=titleName:明*'

9  提供一个postman的下载地址方便进行简单测试

链接:https://pan.baidu.com/s/1AemNf-3xvS7HKxjFkd9jSA 
提取码:jihu 

10 官网查询api地址

https://www.elastic.co/guide/en/elasticsearch/reference/5.0/query-dsl-filtered-query.html

猜你喜欢

转载自blog.csdn.net/Master_chaoAndQi/article/details/83930019