SOLR's client basically has only one, that is SOLRJ,SPRING-DATA-SOLR is done on the basis of SOLRJ encapsulation, so unified into Spring-data style
Official website:
http://projects.spring.io/spring-data-solr/
The simplest way to use spring-data is to use spring-boot, noting that multiple spring-data are not common, since we have also used SPRING-DATA-JPA as an ORM,
A new project is created here to use SPRING-DATA-SOLR as a client for the SOLR server, and then to use it in a distributed, collaborative usage.
First build Spring-boot project, refer to another blog for details.
Add Dependencies:
< Dependency > < groupId >org.springframework.boot</groupId> < Artifactid>spring-boot-starter-data-solr</artifactid> </dependency>
Because Spring-boot is a centralized configuration, the following configuration is added to the application.properties file:
# SOLR (solrproperties) spring.data.solr.host=http://localhost:8983/solr/mark#spring.data.solr.zkhost= Spring.data.solr.repositories.enabled=true
That would be a complete configuration.
Using SPRING-DATA-SOLR is almost as much as using a SPRING-DATA-JPA:
Public Interface extends Solrcrudrepository<searchmark, string> { @Query ("value:?0") List<searchmark > findallbyvalue (String Markey, pageable pageable);}
But there are some differences:
[Email protected] is the SOLR syntax, and the parameter count is starting from 0 (SPRING-DATA-JPA is starting from 1)
2. Each mapped entity class must have a @id primary key
@Entity Public classSearchmarkImplementsSerializable {Private Static Final LongSerialversionuid = 1229830543809682342L; @org. Springframework.data.annotation.IdPrivateString ID;//Unique PRIMARY Key@Field ()PrivateString value;//the value of the label@Field ()Private intType//type@Field ("DATAM_ID") Private intDatamid;//Data ID@Field ("Create_time") @JsonFormat (Pattern= "Yyyy-mm-dd HH:mm:ss", timezone = "gmt+08") PrivateDate Createtime;//creation Time
Note that @id is @org. Springframework.data.annotation.Id
Other usage references:
http://projects.spring.io/spring-data-solr/
http://docs.spring.io/spring-data/solr/docs/1.0.0.RC1/reference/html/
Http://www.petrikainulainen.net/programming/solr/spring-data-solr-tutorial-crud-almost/?utm_source=tuicool &utm_medium=referral
Use SPRING-DATA-SOLR to do SOLR client