ElasticSearch学习

Posted rogersma

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ElasticSearch学习相关的知识,希望对你有一定的参考价值。

一、特点

分布式,高可用,多类型,多API,面向文档(nosql),异步写入,近实时,基于Lucene,Apache协议

二、核心概念

近实时:延时一般在一秒左右,折中方案(每个几秒刷新一次,index.refresh_inteform)
集群: 节点加入集群时要按名字索引,因此时集群名字不要冲突。
节点: 就是集群中的一台主机。
索引: 单个集群中可以根据需要定义多个索引。
类型: 一个索引中包含文档的进一步的细分。一般根据文档的公共属性进行划分。
文档: 进行索引的基本单位,与索引中的内容是相对应的。
分片: 一方面水平分割缩放内容,提高性能吞吐量。
副本: 高可用,分布到多台主机上。

三、ElasticSearch与Sprinboot集成

1、配置 ElasticSearch

Spring Data ElasticSearch
JNA

pom.xml
// 添加 Spring Data Elasticsearch 的依赖
implementation(‘org.springframework.boot:spring-boot-starter-data-elasticsearch‘)
// 添加 JNA 的依赖
implementation(‘net.java.dev.jna:jna:4.3.0‘)

application.properties
# 内嵌 Elasticsearch 实例。默认存储位置是工作目录的 elastic 目录
spring.data.elasticsearch.properties.path.home=target/elastic
# 设置连接超时时间
spring.data.elasticsearch.properties.transport.tcp.connect_timeout=120s

  2、全文搜索

将非结构化数据转为结构化数据,然后创建索引,提高搜索效率。
实现原理:建文本库=》简历索引=》执行搜索=》过滤结果
实现技术:Lucene(引擎)、ElasticSearch(基于Lucene,自带分布式机制,只支持json)、Solr(发动机,第三方分布式管理,数据个数多,实时搜索弱于ES)

 

以上是关于ElasticSearch学习的主要内容,如果未能解决你的问题,请参考以下文章

Elasticsearch 基本概念

Elasticsearch 教程

Elasticsearch 基本概念

SpringBoot-spring-data-elasticsearch7.12.0

elasticsearcch部署

Elasticsearch后台运行步骤