Elastic Search 8.6.2 client actual combat

Elastic Search 8.6.2 client actual combat

Elastic Search interacts with the client and can use many languages ​​​​to complete the search, such as Java, Python, Php, Go and other languages. Since I usually use Java the most, I will only demonstrate it based on the Java language. Clients that can be selected based on Java language include RestClient and Spring Data Elasticsearch. For installation, please refer to " Elastic Search 8.6.2 Cluster Installation and Deployment ".

4.1 Using RestClient [brief introduction]

Reference documentation:

https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/introduction.html

Create the project Spring Boot Web project es-demo and configure the project pom.xml file:

<?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 " target="_blank">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.5.0</version>

<relativePath/> <!-- lookup parent from repository -->

</parent>

<groupId>com.study</groupId>

<artifactId>es-demo</artifactId>

<version>0.0.1-SNAPSHOT</version>

<name>es-demo</name>

<description>Elastic Search Demo project for Spring Boot</description>

<properties>

<java.version>17</java.version>

</properties>

<dependencies>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-web</artifactId>

</dependency>

<dependency>

<groupId>org.elasticsearch.client</groupId>

<artifactId>elasticsearch-rest-client</artifactId>

<version>8.6.2</version>

</dependency>

<dependency>

<groupId>co.elastic.clients</groupId>

<artifactId>elasticsearch-java</artifactId>

<version>8.6.2</version>

</dependency>

<dependency>

<groupId>org.elasticsearch</groupId>

<artifactId>elasticsearch</artifactId>

<version>8.6.2</version>

</dependency>

<dependency>

<groupId>org.projectlombok</groupId>

<artifactId>lombok</artifactId>

</dependency>

</dependencies>

<build>

<plugins>

<plugin>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-maven-plugin</artifactId>

</plugin>

</plugins>

Guess you like

Origin blog.csdn.net/Yu_Yangjun/article/details/129754927