Build your own search engine part 5

I. Introduction

Continue from above Building your own search engine Part 4 , let’s continue to introduce the other two ways of writing the word fennel, bean and fennel.

 二、It is

Jest is the Java Http Rest client of ES. It is mainly used to make up for the lack of HttpRest interface client in ES's own API. However, because ES has officially provided RestClient, the project is no longer maintained.

1. Build JestClient

2. Create an index

3. Simple search

三、Spring Data Elasticsearch

Among the methods introduced earlier, it is not recommended to use TransportClient and Jest in the new version. The official RestClient API is relatively expensive to learn, and Spring Data Elasticsearche has a common interface with other Spring Data members. It's simpler.

Note: We are currently using RestClient in our project.

1、Spring Data

Spring Data is a sub-project of Spring, mainly to simplify database access. It supports NoSQL and relational database access. Its core concept is a Repository interface.

Note: Next time I will compile an introduction to various database accesses in Spring Data.

2、Spring Data Elasticsearch

The latest version of Spring Data EasticSearch is 4.3. The TransportClient module that interfaced with ES was abandoned in 4.0. The corresponding one now should be RestClient (to be confirmed).

3. Add dependencies

4. application.yml configuration connection

Note: ES default installation access does not require authorization. Next time, the authorization configuration will be sorted out.

5. Define entity classes

Note: Mainly the annotations @Document, @Field and other definitions provided by Spring-data-Es.

6. Define the Repository interface

Note: Respository provides basic addition, deletion, modification and query interfaces by default. If you need to extend the interface, you can define the interface according to the specification. All data interfaces are unified specifications.

7. Create indexes and queries

Note: The four APIs using Spring-Data-ES are relatively the simplest. Simple things are the best. It reminds me of the vernacular advocated by Chen Duxiu, Hu Shi and others in the awakening era.

Guess you like

Origin blog.csdn.net/2301_76787421/article/details/133420300