elastic-search 部署和应用「详细」

码途镂虹使
• 阅读 1020

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.0
http.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目录下进行解压
    elastic-search 部署和应用「详细」
  • es重启后会加载ik
    elastic-search 部署和应用「详细」

    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=localhost
elasticsearch.port=9200

es配置文件移步

点赞
收藏
评论区
推荐文章
Irene181 Irene181
4年前
手把手教你使用Flask搭建ES搜索引擎(预备篇)
/1前言/Elasticsearch是一个开源的搜索引擎,建立在一个全文搜索引擎库ApacheLucene™基础之上。那么如何实现Elasticsearch和Python的对接成为我们所关心的问题了(怎么什么都要和Python关联啊)。/2 Python交互/所以,Python也就提供了可以对接Elasti
Stella981 Stella981
3年前
Elasticsearch学习总结一 基本用法及概念
一.Elasticsearch是一个基于Lucene的实时的分布式搜索和分析引擎。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。基于RESTful接口二.ES中的核心概念集群(Cluster):ES是一个分布式的搜索引擎,一般由多台物理机组成。这些物理机,通过配置一个相同的clustername,互相发现,把自己
Stella981 Stella981
3年前
ElasticSearch(增put、删delete、改(本质是先删除后添加)post、查get、post)
一、ElasticSearch简介1.1什么是ElasticSearchElasticSearch,简称es,es是一个开源的高扩展的分布式全文搜索引擎,可以近乎实时的存储、检索数据;本身扩展性很好,可以扩展到上百台服务器,处理pb级别的数据。es也使用java开发并使用Lucene作为其核心来实现所有索
Stella981 Stella981
3年前
Elasticsearch与Solr优缺点比较
Elasticsearch简介Elasticsearch是一个实时的分布式搜索和分析引擎。它可以帮助你用前所未有的速度去处理大规模数据。它可以用于全文搜索,结构化搜索以及分析,也可以将这三者进行组合。Elasticsearch是一个建立在全文搜索引擎ApacheLucene™基础上的搜索引擎,可以说Lucen
Stella981 Stella981
3年前
071. ElasticSearch 应用场景及核心概念
1\.ES使用场景给网站/APP添加搜索功能。存储、分析数据。管理、交互、分析空间信息,将ES用于GIS。2\.ES简介Elasticsearch是一个基于Lucene构建的开源、分布式、RESTful接口全文检索引擎。Elast
Easter79 Easter79
3年前
SpringBoot2.0高级案例(09):整合 ElasticSearch框架,实现高性能搜索引擎
本文源码码云地址:知了一笑https://gitee.com/cicadasmile/middlewareparent一、安装和简介ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTfulweb接口。Elasticsearc
Stella981 Stella981
3年前
ElasticSearch学习汇总
什么是ElasticSearch?ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTfulweb接口。Elasticsearch是用Java语言开发的,并作为Apache许可条款下的开放源码发布,是一种流行的企业级搜索引擎。ElasticSearch能够做到实时搜索并且稳定,
Stella981 Stella981
3年前
ELK部署检测nginx日志demo
ELKE:ElasticSearch搜索引擎存储https://www.elastic.co/cn/downloads/elasticsearch(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fwww.elastic.co%2Fcn%2Fdownloads%2F
Stella981 Stella981
3年前
SpringBoot2.0高级案例(09):整合 ElasticSearch框架,实现高性能搜索引擎
本文源码码云地址:知了一笑https://gitee.com/cicadasmile/middlewareparent一、安装和简介ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTfulweb接口。Elasticsearc
陈占占 陈占占
3年前
Django 配置搜索引擎 haystack 与 搜索页面无法返回数据问题
Django配置搜索引擎haystack与搜索页面无法返回数据问题1、Django安装haystackwhooshjiebahaystack是django的开源搜索框架,该框架支持Solr,Elasticsearch,Whoosh,搜索引擎量。Whoosh是一个搜索引擎使用,这是一个由纯Python实现的全文搜索引擎,没有二进制文
王仕宇编程 王仕宇编程
6个月前
Springboot2.x整合ElasticSearch7.x实战(一)
ElasticSearch是一个开源的搜索引擎,建立在一个全文搜索引擎库ApacheLucene™基础之上。Lucene可以说是当下最先进、高性能、全功能的搜索引擎库——无论是开源还是私有。