zoukankan      html  css  js  c++  java
  • elasticsearch5.5.2环境搭建

    运行elasticsearch5.5.2需要jdk1.8版本以上

    1.elasticsearch可以去官网或github下载,window系统推荐zip压缩版

    2.解压后 进入bin目录运行elasticsearch.bat启动服务

    3.访问localhost:9500测试是否成功

    4.安装中文分词插件:https://github.com/medcl/elasticsearch-analysis-ik上下载对应elasticsearch版本的ik分词器

    5.停止elasticsearch服务,解压分词器放入elasticsearch安装目录下的plugins目录中

    6.重启elasticsearch服务器,看到加载ik插件表示安装分词插件成功。

    7.安装Kibana方便用于elasticsearch交互,访问官网下载,推荐下载zip压缩版,与elasticsearch版本要对应

    8.解压,进入bin目录 window下执行kibaba.bat启动kibaba服务。

    9.访问localhost:5601测试是否成功

    以上1-7步完成基本上可以开始与项目整合开发了

    下面是一些常用请求:

    GET localhost:9200 获取当前当前节点、集群、版本等信息

    GET localhost:9200/_cat/indices?v 查看当前节点的所有Index

    GET localhost:9200/_mapping?pretty=true 列出每个Index所包含的Type(建立索引时的mapping结构)

    PUT localhost:9200/weather  新建一个名字为weather的Index

    DELETE localhost:9200/weather 删除名字为weather的Index

    PUT localhost:9200/weather

    {
      "mappings": {
        "typeName": {
          "properties": {
            "title": {
              "type": "text",
              "analyzer": "ik_max_word"
            },
            "desc": {
              "type": "text",
              "analyzer": "ik_max_word"
            }
          }
        }
      }
    }
    新建Index时候也可以同时发送一个mappings,用于映射Index的Type属性结构
    PUT localhost:9200/weather/beijing/1
    {
      "title":"1月份天气",
      "desc":"阳光很好"
    }
    给weather索引的beijing类型(即Document的分组)新增一条id为1的文档
    POST localhost:9200/weather/beijing
    {
      "title":"2月份天气",
      "desc":"阴天"
    }
    新增记录的时候也可以不指定id,请求方式要改成POST
    注意,如果没有先创建 Index(这个例子是weather),直接执行上面的新增命令,Elastic 也不会报错,而是直接生成指定的 Index。
    GET localhost:9200/weather/beijing/1?pretty=true  查看id为1的这条记录,pretty=true表示以已读的形式返回
    DELETE localhost:9200/weather/beijing/1  删除id为1的记录
    PUT localhost:9200/weather/beijing/1
    {
        "title" : "3月份天气",
        "desc" : "晴转多云"
    }
    更新id为1的这条记录
    GET localhost:9200/weather/beijing/_search  查询weather索引的beijing类型的所有文档
    GET localhost:9200/weather/beijing/_search
    {
      "query" : { "match" : { "desc" : "多云 晴" }}
    }
    全文检索weather索引的beijing类型中文档的desc属性值匹配“多云” or “晴”这个词的前10条记录
    GET localhost:9200/accounts/person/_search
    {
      "query": {
        "bool": {
          "must": [
            { "match": { "desc": "多云" } },
            { "match": { "desc": "晴" } }
          ]
        }
      }
    }
    布尔查询

    参考:http://www.ruanyifeng.com/blog/2017/08/elasticsearch.html  
    全文搜索引擎 Elasticsearch 入门教程
    https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html  Elasticsearch: 官方参考文档

    https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.html  
    Elasticsearch: 权威指南
    http://www.bayescafe.com/database/elasticsearch-using-index-or-type.html  ElasticSearch: Index 和 Type 的区别

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

    http://hao.jobbole.com/kibana/  
    Kibana:分析及可视化日志文件

    https://www.elastic.co/guide/en/kibana/current/index.html  KIbana使用指南

    http://www.cnblogs.com/xing901022/p/4704319.html  
    Elasticsearch+Logstash+Kibana教程

    http://www.jianshu.com/p/40b7fbc924b1  elasticsearch 5.4 JAVA API 使用
    http://blog.csdn.net/ljc2008110/article/details/48652937  ElasticSearch的Java API
    http://www.jianshu.com/p/b46587445c1c  Elasticsearch java api 概述
    https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.html  Transport Client官方文档
     
     
     
     
     
     
     
     
  • 相关阅读:
    sass学习笔记1
    javascript 数组的深度复制
    div+css定位position详解
    滚动加载图片(懒加载)实现原理
    移动端布局经验
    js 扁平化输出数组
    axiso基本使用及python接收处理
    JSP内置对象
    JSP基本语法
    tomcat环境搭建
  • 原文地址:https://www.cnblogs.com/hihtml5/p/7497518.html
Copyright © 2011-2022 走看看