“This is the 21st day of my participation in the First Challenge 2022. For details: First Challenge 2022”

One, foreword

Elasticserach jar for manipulation of Elasticserach is already packaged in the spring family. Spring-data-elasticsearch makes it a lot easier for you to handle Elasticserach, but there are a few pitfalls, which we’ll explain in more detail below.

Second, the problem of

  1. (ElasticSearch 5.6.80, ElasticSearch 6.4.2, ElasticSearch 7.5.0) For example, es5.6.80 also supports the creation of multiple types in an index. However, after 6.4.2 and 7.5.0, it does not support the creation of multiple types.

  2. The plan is to use springboot+ Spring-data-ElasticSearch es, which only needs to import the following Maven coordinates:

<! -- Out of the box, <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> </dependency>Copy the code

Springboot: elasticSearch: elasticSearch: elasticSearch: elasticSearch: elasticSearch: elasticSearch: elasticSearch: elasticSearch: elasticSearch: elasticSearch: elasticSearch: elasticSearch: elasticSearch: elasticSearch: elasticSearch: elasticSearch: elasticSearch: elasticSearch: elasticSearch: ElasticSearch: ElasticSearch: ElasticSearch: ElasticSearch: ElasticSearch: ElasticSearch: ElasticSearch: ElasticSearch: ElasticSearch: ElasticSearch: ElasticSearch: ElasticSearch: ElasticSearch

IO /spring-data…

  1. The spring-data-ElasticSearch API varies between different versions of elasticSearch. Do not upgrade at will

  2. Upgrading SpringBoot from 2.0.3 to 2.2.0 will cause cyclic dependency injection problems. For example, springBoot relies on class B in class A, and then depends on class A in class B, causing startup errors. There was no problem with SpringBoot in version 2.0.3. It is suspected that SpringBoot 2.2.0 has a different treatment for cyclic dependencies. It is also easy to fix this problem by adding @lazy annotations to the self-injected annotations as shown below:

public class A{
@Autowired
@Lazy
privateB b; . }public class B{
@Autowired
@Lazy
privateA a; . }Copy the code

How to install and use ElasticSearch: blog.csdn.net/weter_drop/…