当前位置: 首页 > news >正文

Elasticsearch6.x和7.x的区别

Elasticsearch6.x和7.x的区别

1、查找方面的区别

在增删改方面,6.x7.x是一样的,在查找方面(分为普通查找和有高亮的查找),6.x7.x有区别。

7.x的es中:

  • org.springframework.data.elasticsearch.core.SearchResultMapper没有这个类了

  • org.springframework.data.elasticsearch.core.ElasticsearchTemplate 已废弃

  • org.springframework.data.elasticsearch.repository.ElasticsearchRepository<T,

ID>.search(org.springframework.data.elasticsearch.core.query.Query) 已废弃

于是在普通查找带高亮的查找方面,es6.x和7.x不一样。

2、配置文件的区别

es6.x application.properties

# 旧版本以spring.data.elasticsearch.开头;访问地址配置不用声明访问协议,监听es的tcp端口
# 7.x已经弃用了
spring.data.elasticsearch.cluster-name=my-application
spring.data.elasticsearch.cluster-nodes=127.0.0.1:9300

es7.x application.properties

# 新版本以spring.elasticsearch.rest.开头;访问地址配置需要声明访问协议,直接监听es访问端口
spring.elasticsearch.rest.uris=http://localhost:9200

3、Document注解的type属性

es6.x 有type = “_doc”

@Document(indexName = "discusspost", type = "_doc", shards = 6, replicas = 3)
public class DiscussPost {}

es7.x 无type = “_doc”

@Document(indexName = "discusspost", shards = 6, replicas = 3)
public class DiscussPost {}

4、Elasticsearch Clients的区别

下方内容来自官方文档:

https://docs.spring.io/spring-data/elasticsearch/docs/4.0.1.RELEASE/reference/html/#reference

ES6.x:Transport Client

@Configuration
public class TransportClientConfig extends ElasticsearchConfigurationSupport {@Beanpublic Client elasticsearchClient() throws UnknownHostException {Settings settings = Settings.builder().put("cluster.name", "elasticsearch").build();        TransportClient client = new PreBuiltTransportClient(settings);client.addTransportAddress(new TransportAddress(InetAddress.getByName("127.0.0.1"), 9300)); return client;}@Bean(name = { "elasticsearchOperations", "elasticsearchTemplate" })public ElasticsearchTemplate elasticsearchTemplate() throws UnknownHostException {return new ElasticsearchTemplate(elasticsearchClient());}
}

ES7.x:High Level REST Client

@Configuration
public class RestClientConfig extends AbstractElasticsearchConfiguration {@Override@Beanpublic RestHighLevelClient elasticsearchClient() {final ClientConfiguration clientConfiguration = ClientConfiguration.builder()  .connectedTo("localhost:9200").build();return RestClients.create(clientConfiguration).rest();                         }
}
http://www.lryc.cn/news/117935.html

相关文章:

  • 基于STM32设计的口罩识别和无线测温系统
  • 第五十天
  • vue-pc端elementui-统一修改问题-Dialog 对话框点击空白关闭问题-element-所有组件层级问题
  • VS code 用户设置
  • 【Spring security 解决跨域】
  • 【C语言】经典题目(四)
  • Prometheus-监控 Postgresql
  • Android java.lang.UnsatisfiedLinkError: No implementation found
  • Leecode力扣704数组二分查找
  • Linux 的基本使用
  • vue3实现自定义select下拉框内容之城市区域篇
  • 性能测评:腾讯云轻量应用服务器_CPU内存带宽流量
  • python中的迭代器和生成器
  • Python-OpenCV中的图像处理-图像阀值
  • VB+SQL酒店客房管理设计与实现
  • 【Linux】从0到1实现一个进度条小程序
  • 江南大学轴承数据故障诊断(利用一维CNN进行故障诊断,代码和数据放在压缩包,无需修改任何东西,解压缩后直接运行,有详细注释)
  • 【网络基础实战之路】基于BGP协议连接三个AS区域的实战详解
  • 基于Python爬虫+词云图+情感分析对某东上完美日记的用户评论分析
  • Day 26 C++ list容器(链表)
  • 【深度学习注意力机制系列】—— SKNet注意力机制(附pytorch实现)
  • Markdown语法和表情
  • CSDN编纂目录索引跳转设置
  • cpu的架构
  • FastAPI和Flask:构建RESTful API的比较分析
  • 用康虎云报表打印二维码
  • 网盘直链下载助手
  • 【EI复现】售电市场环境下电力用户选择售电公司行为研究(Matlab代码实现)
  • 并发——何谓悲观锁与乐观锁
  • 【C++】模板