• windows 系统配置(三)Elasticsearch&Kibana 安装


    为什么学习Elasticsearch?

      众所周知 Lucene 可以说是当下最先进、高性能、全功能的搜索引擎库。但是Lucene 非常复杂,于是Elasticsearch便诞生了,全文检索变得更简单!

      (开源的支持分布式)

    下载:

      https://www.elastic.co/cn/downloads/elasticsearch

    github:

      https://github.com/elastic/elasticsearch

    官网文档:

      https://www.elastic.co/guide/index.html

    选一个合适的版本下载。如果想要找老版本-》大家可以选择更稳定的版本下载^^。

    之前我下了一个较高的版本7.x,毕竟本地的jdk 版本较低,所以又换回低版本了6.x > < 。

        

    安装分词插件:找一个对应的版本

      https://github.com/medcl/elasticsearch-analysis-ik/releases

    github:

      https://github.com/medcl/elasticsearch-analysis-ik

    install:

      ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.x.x/elasticsearch-analysis-ik-6.x.x.zip

    看一下结果:

    1.

     2.

     启动

    启动默认端口:9200 ;java中访问为:9300

     访问一下看看:

    查看节点状态:

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

    查看集群健康状态:

      http://localhost:9200/_cat/health?v

    查看所有索引信息:

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

    这是没有索引:

    这是7.9 已经有索引了

    ***它的配置文件在config中 7.9

    6.2 还是有一些区别的

     elasticsearch.yml

    集群名称

      节点名称

    网络地址和端口

      数据存储地址和日志存储地址

    Kibana

      Kibana 是为 Elasticsearch设计的开源分析和可视化平台。即客户端。

     下载:

      https://www.elastic.co/cn/downloads/kibana

     解压:

    启动:kibana.bat

     

    启动后:

    启动后默认端口:5601

    6.2 的页面

    这是7.9 的页面

    6.2 配置文件:

    7.9 配置文件:

    7.9 这里可以下一些演示数据。Try our sample data

    进入页面之后看一下左侧导航-》

    Discover 搜索查看数据

    Dashboard 制作仪表盘

    Visualize 制作可视化视图

    Dev Tools 开发者工具

     这是7.9版本中我下的演示数据 ,在Discover中可以查看

     

     开发者工具页面:点Get to work

    索引:

    创建索引:

     

     创建索引和查看所有索引 代码:

    GET /_cat/indices?v
    put /test

     ***遇到的问题(一) 点击request 没反应。。所以在kibana.yml 中把这句话放开改了一下。

    删除索引:

    DELETE /test

    做一个增删改查CRUD操作

    创建文档:-》POST index/type/id {巴拉巴拉}

     

     获取数据

     修改:

     结果:

     删除:

     结果:

     测试代码:

    GET /_cat/indices?v
    put /test
    PUT /test2
    DELETE /test2
    
    POST /test/user/1
    {
      "name":"我是谁?",
      "age":20,
      "address":"我在哪小区"
    }
    
    GET /test/user/1
    
    
    POST /test/user/1/_update
    {
      "doc":{
        "age":21
      }
    }
    
    DELETE /test/user/1

     查询:

     首先创建一些测试数据:

    POST /test/user/1
    {
      "name":"我是谁?",
      "age":20,
      "address":"我在哪小区"
    }
    
    POST /test/user/2
    {
      "name":"小明",
      "age":21,
      "address":"A区"
    }
    
    POST /test/user/3
    {
      "name":"小乔",
      "age":16,
      "address":"B区"
    }
    View Code

     DSL参考文档:

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

     

    用DSL

    代码:

    GET /test/user/_search?q=A
    
    GET /test/user/_search
    {
      "query": {
        "match": {
          "address":"A"
        }
      }
    }

    springboot 中用到的pom

        <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
            </dependency>

    @

  • 相关阅读:
    用Margin还是用Padding?
    更优雅的清除浮动float方法
    清除浮动float (:after方法)
    px,em,rem
    load()方法
    PHP函数详解:call_user_func()使用方法
    移动端touch事件影响click事件以及在touchmove添加preventDefault导致页面无法滚动的解决方法
    Mysql开启远程连接方法
    mysql的字符串连接符
    php使用curl访问https返回无结果的问题
  • 原文地址:https://www.cnblogs.com/DarGi2019/p/13601946.html
Copyright © 2020-2023  润新知