ES、kibana安装及交互操作
发布日期:2021-05-09 04:59:15 浏览次数:16 分类:博客文章

本文共 2489 字,大约阅读时间需要 8 分钟。

一、ES的安装与启动

1、ES安装(Windows环境)

  • 下载地址:https://www.elastic.co/cn/downloads/past-releases#elasticsearch
  • 版本:6.3.2
  • 运行环境:jdk1.8以上
  • 双击.bat启动

2、查看效果

浏览器输入:http://localhost:9200,返回如下json。

{  "name" : "RDFnj43",  "cluster_name" : "elasticsearch",  "cluster_uuid" : "X-h3NABsTPOitRIeqIJj4Q",  "version" : {    "number" : "6.3.2",    "build_flavor" : "default",    "build_type" : "zip",    "build_hash" : "053779d",    "build_date" : "2018-07-20T05:20:23.451332Z",    "build_snapshot" : false,    "lucene_version" : "7.3.1",    "minimum_wire_compatibility_version" : "5.6.0",    "minimum_index_compatibility_version" : "5.0.0"  },  "tagline" : "You Know, for Search"}

证明启动成功

二、kibana安装及启动

1、kibana安装(Windows环境)

  • 下载地址:https://www.elastic.co/cn/downloads/past-releases#kibana
  • 版本:6.3.2
  • 运行环境:jdk1.8以上
  • 双击.bat启动

2、查看效果

浏览器输入:http://localhost:5601,如下所示,证明启动成功

 

三、交互操作

1、ES与mysql的对应关系理解

 

2、使用postman与ES交互操作案例

 

Get 查看所有索引localhost:9200/_allPUT 创建索引-testlocalhost:9200/test  DEL 删除索引-testlocalhost:9200/test  PUT 创建索引-person-1localhost:9200/personPUT 新增数据-person-1localhost:9200/person/_doc/1{    "first_name" : "John",  "last_name" : "Smith",  "age" : 25,  "about" : "I love to go rock climbing",  "interests" : [ "sports", "music" ]}PUT 新增数据-person-2localhost:9200/person/_doc/2{    "first_name" : "Eric",  "last_name" : "Smith",  "age" : 23,  "about" : "I love basketball",  "interests" : [ "sports", "reading" ]}GET 搜索数据-person-idlocalhost:9200/person/_doc/1GET 搜索数据-person-namelocalhost:9200/person/_doc/_search?q=first_name:john{  "took": 56,  "timed_out": false,  "_shards": {    "total": 1,    "successful": 1,    "skipped": 0,    "failed": 0  },  "hits": {    "total": {      "value": 1,      "relation": "eq"    },    "max_score": 0.6931472,    "hits": [      {        "_index": "person",        "_type": "_doc",        "_id": "1",        "_score": 0.6931472,        "_source": {          "first_name": "John",          "last_name": "Smith",          "age": 25,          "about": "I love to go rock climbing",          "interests": [            "sports",            "music"          ]        }      }    ]  }}
  • GET为查询操作
  • PUT为创建索引
  • DELETE为删除索引

3、使用kibana与ES交互操作

找到dev tools,进行交互操作

//查询所有的索引GET _all1 //按照id查询 GET person/_doc/2

与es交互式操作格式:

POST /person/_search{  "query": {    "bool": {      "must": [        {          "match": {            "interests": "FOOTBALL"          }        },        {          "match": {            "userName": "ESRC22"          }        }      ]    }  }}
  • must为且的关系
  • must处为should的时候为或的关系

 

上一篇:Mysql、ES 数据同步
下一篇:tl-wr742n 怎么设置dns

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2025年03月27日 17时06分11秒