zoukankan      html  css  js  c++  java
  • ES、kibana安装及交互操作

    一、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/_all
    
    PUT 创建索引-test
    
    localhost:9200/test  
    
    
    DEL 删除索引-test
    
    localhost:9200/test  
    
    
    PUT 创建索引-person-1
    
    localhost:9200/person
    
    
    PUT 新增数据-person-1
    
    localhost:9200/person/_doc/1
    
    {
        "first_name" : "John",
      "last_name" : "Smith",
      "age" : 25,
      "about" : "I love to go rock climbing",
      "interests" : [ "sports", "music" ]
    }
    
    PUT 新增数据-person-2
    
    localhost:9200/person/_doc/2
    
    {
        "first_name" : "Eric",
      "last_name" : "Smith",
      "age" : 23,
      "about" : "I love basketball",
      "interests" : [ "sports", "reading" ]
    }
    
    GET 搜索数据-person-id
    
    localhost:9200/person/_doc/1
    
    GET 搜索数据-person-name
    
    localhost: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的时候为或的关系
  • 相关阅读:
    JS的type类型为 text/template
    Vue之x-template(2)
    Vue之x-template(1)
    vue之$mount
    console.log()与console.dir()
    Less用法注意事项
    一次 Linux 系统被攻击的分析过程
    WebAR 如何改变增强现实的未来
    开发中的测试名词解释
    Flutter 同步系统的 HTTP 代理设置
  • 原文地址:https://www.cnblogs.com/longronglang/p/12006939.html
Copyright © 2011-2022 走看看