es简介

  • Elasticsearch 是一个分布式可扩大的实时搜寻和剖析引擎,一个建设在全文搜索引擎 Apache Lucene(TM) 根底上的搜索引擎

Elastic官网

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

次要性能:

  • 分布式搜寻
  • 数据分析
  • 分组和聚合

es下载地址

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

linux装置es

  • 将下载的安装包上传导linux服务器,我的版本是elasticsearch-7.2.0-linux-x86_64.tar.gz
  • 创立usr/local/soft/es目录,将es解压到这个目录中
  • 批改es的yum文件
node.name: node-1// 这个很重要http.host: 0.0.0.0http.port: 9200
  • 批改es的jvm.options
-Xms256M-Xmx256M
  • 创立新的用户来启动es

    • useradd esuser
    • 赋予权限

      chown -R esuser:esuser /usr/local/software/elasticsearch-7.2.0
    • 切换到esuser用户

      su esuser
  • 通过es用户后盾启动es

    sh elasticsearch -d
  • 验证是否启动胜利
curl -X GET "http://localhost:9200"

增加ik到es中

  • 下载ik的版本必须和es版本对应
  • 将ik放到es的plugin目录下进行解压
  • es重启后会加载ik

    es中新增索引post

    curl -X PUT "localhost:9200/post" 

将分词器批改成ik

  • 敞开索引
POST post/_close
  • 配置ik
PUT post/_settings{  "number_of_replicas": 0,  "index":{    "analysis.analyzer.default.type":"ik_max_word",    "analysis.search_analyzer.default.type":"ik_smart"  }}
  • 开启post索引
POST post/_open

创立es的mapping,依据本人的需要创立

curl --location --request PUT '787k.fun:9200/post/_mapping' \--header 'Content-Type: application/json' \--data-raw '{    "properties": {        "id": {            "type": "integer"        },        "title": {            "type": "text"        },        "content": {            "type": "text"        },        "blogImg": {            "type": "keyword"        },        "html_content": {            "type": "keyword"        },        "authorId": {            "type": "integer"        },        "authorName": {            "type": "keyword"        },        "tag": {            "type": "integer"        },        "type": {            "type": "integer"        },        "status": {            "type": "integer"        },        "commentCount": {            "type": "integer"        },        "score": {            "type": "double"        },        "created": {            "type": "date"        },        "updated": {            "type": "date"        }    }}'

springboot集成es

  • pom文件退出依赖
    <!--es开始-->    <dependency>      <groupId>org.elasticsearch.client</groupId>      <artifactId>elasticsearch-rest-high-level-client</artifactId>      <version>7.2.0</version>    </dependency>    <dependency>      <groupId>org.elasticsearch</groupId>      <artifactId>elasticsearch</artifactId>      <version>7.2.0</version>    </dependency>    <!--es完结-->
  • yum文件增加文件
elasticsearch.host=localhostelasticsearch.port=9200

es配置文件移步