pom文件
可以写在实体类中,不要引入其他es的pom 容易出错
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
实体类
@Data
@Document(indexName = "blogs")
public class Search {
@Id
private Integer articleId;
@Field(type = FieldType.Text, analyzer = "ik_smart") //需要分词查询的
private String articleTitle;
@Field(type = FieldType.Text, analyzer = "ik_smart") //需要分词查询的
private String articleContext;
}
服务端
引入yml文件
server:
port: 8016
spring:
application:
name: search-service
elasticsearch: #es的地址
rest:
uris: http://192.168.133.152:9200
eureka:
client:
service-url:
defaultZone: http://localhost:8000/eureka