GithubHelp home page GithubHelp logo

spring-elasticsearch's Introduction

spring-elasticsearch

使用spring-boot-starter-data-elasticsearch集成ES:
1.修改pom文件

<dependency>  
    <groupId>org.springframework.boot</groupId>  
    <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>

2.配置application.properties文件

#elasticsearch 
 spring.data.elasticsearch.cluster-name=elasticsearch  
 spring.data.elasticsearch.repositories.enabled=true  
 spring.data.elasticsearch.cluster-nodes=localhost:9300

3.新建一个接口继承ElasticsearchRepository,此时默认的增删改查就已经存在了

@Component  //让spring管理
public interface ElasticRepository extends ElasticsearchRepository<T, Long> {
}

4.根据jpa的命名方式,在接口中新建方法(不需要实现)

关键字 方法命名示例
And findByNameAndNum
Or findByNameOrDiscription
Between findByNumBetween
Like findByNameLike
NotLike findByNameNotLike
OrderBy findByIdOrderByXDesc
Not findByNameNot

5.注入到Controller中,调用方法时给上对应的参数即可。

6.复杂查询使用ElasticsearchTemplateTransportClient

spring-elasticsearch's People

Contributors

zengxin166850 avatar

Watchers

James Cloos avatar

Forkers

uso-800

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.