Easy-Es Easy-Es
💋Home
  • v2.0.0(current version)
  • What's New

    • What' s New In Easy-Es v2.0.0?
  • history version

    • v1.x.x
  • Upgrade guide

    • Upgrade to 2.x.x instructions
💖Support
  • OS Community
  • Recommend Goods
  • Project PPT (opens new window)
  • Project introduction
  • Project members
  • PR
Join
Customer
  • Doc-Apis (opens new window)
  • Fitness plan automatic generation system (opens new window)
  • Vuepress-theme-vdoing (opens new window)
  • Gitee (opens new window)
  • Github (opens new window)
  • 简体中文 (opens new window)
  • English (opens new window)

adv display by random ❤️become sponsor
💋Home
  • v2.0.0(current version)
  • What's New

    • What' s New In Easy-Es v2.0.0?
  • history version

    • v1.x.x
  • Upgrade guide

    • Upgrade to 2.x.x instructions
💖Support
  • OS Community
  • Recommend Goods
  • Project PPT (opens new window)
  • Project introduction
  • Project members
  • PR
Join
Customer
  • Doc-Apis (opens new window)
  • Fitness plan automatic generation system (opens new window)
  • Vuepress-theme-vdoing (opens new window)
  • Gitee (opens new window)
  • Github (opens new window)
  • 简体中文 (opens new window)
  • English (opens new window)
  • Quick start

    • Introduction
    • Applicable scene
    • Worry free
    • Avoid pit
    • Quick start
    • Springboot demo
      • 1. Project structure
      • 2.Pom
      • 3. Core code
      • 4. Start and use
        • a.Add configuration information
        • b.Start the project
        • c.Use
      • 5 Conclusion
    • Config
    • Annotation
  • Core functions

    • Auto process index
    • CRUD
    • Condition constructor
  • Extended function

    • Mixed query
    • Origin query
    • Page
    • Nested
    • Join Parent child
    • Get DSL
  • High-level syntax

    • Field filtering
    • Sort
    • Aggregation
    • Match
    • Weight
    • Highlight
    • Geo
  • Plugin

    • Plugin
  • Other

    • Faq
    • Difference from MP
    • MySQL and EE syntax comparison
    • Update log
    • Update plan
    • Copyright
    • Thanks
  • v1.xDoc
  • Quick start
LaoHan
2023-03-18
目录

Springboot demo

highly recommended

This Demo demonstrates the seamless integration between Easy-Es and the Springboot project. It is strongly recommended to download it first and run it directly in your local area to avoid stepping on the pit due to version compatibility issues such as springboot when integrating it yourself.

Demo download address: ✔Gitee (opens new window) | ✔Github (opens new window)

# Demo introduction

# 1. Project structure

1


For the convenience of demonstration, this demo omits the service layer

# 2.Pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>ee-use</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>ee-use</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>cn.easy-es</groupId>
            <artifactId>easy-es-boot-starter</artifactId>
            <version>${Latest version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

special attention

Please refer to the figure below to get the latest version of the latest version currently released. The actual version number is filled in, such as 1.0.0, not the latest version!!!

In addition, because springboot is built-in associated with the es version, different springboot versions will cause the es dependency version introduced in the actual project to be too low or too high. However, the compatibility of different versions of es is relatively poor, causing many users to step on the pit of some compatibility problems. I hereby remind users that if the version of es that your project actually depends on is not For version 7.14.0, we strongly recommend that you specify that the es-dependent jar package version is 7.14.0, which is consistent with the es-dependent version we use at the bottom, so the compatibility is the best, It is not easy to step on the pit. The reason why the bottom layer adopts 7.14.0 is also after multiple investigations, and a stable version without security vulnerabilities was selected, which was scanned by Murphy to be safe and reliable. As for the ES client version, the 7.10+ measured compatibility is very good. It doesn't matter if the jar package version in the dependency does not match the client version, the focus is on the dependent Jar version.

Latest Version: Maven Central (opens new window)

# 3. Core code

@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class TestUseEeController {
    private final DocumentMapper documentMapper;
    
    @GetMapping("/insert")
    public Integer insert() {
        // Initialize -> add data
        Document document = new Document();
        document.setTitle("man");
        document.setContent("muscle man");
        return documentMapper.insert(document);
    }

    @GetMapping("/search")
    public List<Document> search() {
        // Query a list of all documents with the title man
        LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();
        wrapper.eq(Document::getTitle, "man");
        return documentMapper.selectList(wrapper);
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

# 4. Start and use

# a.Add configuration information

easy-es:
  enable: true # The default is true, if it is false, the framework is considered not to be enabled
  address : 127.0.0.0:9200 #Fill in your es connection address
  # username: Fill in only if there are settings, not required
  # password: Fill in only if there are settings, not required
1
2
3
4
5

# b.Start the project

Start the project with your IDE

image.png

If your configuration is correct and the ES version and Springboot version are compatible, you will see that the ES index is automatically created by the framework and output in the console: ===>Congratulations auto process index by Easy-Es is done !

# c.Use

http://localhost:8080/insert (opens new window) (Click to insert data)

http://localhost:8080/search (opens new window) (Click to query)

# 5 Conclusion

At this point, you have initially experienced the basic functions of Easy-Es. If you feel that the experience is not bad, and want to experience more powerful functions, then keep reading!

Help us improve this document (opens new window)
Last update: 2024/03/29
Quick start
Config

← Quick start Config→

Theme by Vdoing | Copyright © 2021-2025 LaoHan | Zhejiang ICP No. 2022020479 | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式