一、使用curl命令进行交互

创建索引

[root@es01 ~]# curl -XPUT '10.0.0.5:9200/student?pretty'
{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "student"
}

数据插入

[root@es01 ~]# curl -XPUT '10.0.0.5:9200/student/_doc/1?pretty' -H 'Content-Type: application/json' -d '{"name": "xm","sex":"male","age":"18","hobby":["swimming","basketball"]}'
{
  "_index" : "student",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}

数据获取

[root@es01 ~]# curl -GET '10.0.0.5:9200/student/_doc/1?pretty'
{
  "_index" : "student",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 1,
  "_seq_no" : 0,
  "_primary_term" : 1,
  "found" : true,
  "_source" : {
    "name" : "xm",
    "sex" : "male",
    "age" : "18",
    "hobby" : [
      "swimming",
      "basketball"
    ]
  }
}

二、使用elasticsearch-head进行交互

  elasticsearch-head是一个Web前端,用于浏览Elasticsearch集群和交互,它有多种方式安装运行:
  最简单的就是从Chrome网上应用店安装ElasticSearch Head,地址:https://chrome.google.com/webstore/detail/elasticsearch-head/ffmkiejjmecolpfloofpjologoblkegm/
  当然也可以在服务器做为一个独立的web应用来使用,具体方法:https://github.com/mobz/elasticsearch-head

三、使用Kibana进行交互

这里只是简单用它和Elasticsearch进行交互,后面文章会详细介绍到Kibana。
安装

[root@es01 ~]# wget https://artifacts.elastic.co/downloads/kibana/kibana-7.10.0-x86_64.rpm
[root@es01 ~]# rpm -vih kiana-7.10.0-x86_64.rpm
[root@es01 ~]# vim /etc/kibana/kibana.yml    # 修改以下配置
server.port: 5601
server.host: "10.0.0.5"
elasticsearch.hosts: ["http://10.0.0.5:9200"]
[root@es01 ~]# systemctl start kibana
[root@es01 ~]# netstat -ntlp
tcp        0      0 10.0.0.5:5601           0.0.0.0:*               LISTEN      11066/node 

访问

找到Dev Tools点击进入,就可以Elasticsearch进行交互了。

发表评论

验证码: 85 − = 80