Implementation code of spring boot integrated sorl search client

Apache Solr is a search engine. Spring boot provides basic configuration for Solr client library and the abstraction based on Solr client library provided by spring data Solr. Spring boot provides a spring boot starter data Solr 'starter POM' for aggregating dependencies.

Spring boot starter data Solr dependency is introduced in POM The following contents are added to the XML configuration file (based on the pom.xml file in the previous chapter "spring boot construction framework"):

You can inject an automatically configured solrserver instance like other spring beans. By default, the instance will try to connect to a server using localhost: 8983 / Solr.

If you add a @ bean of your own solrserver type, it will replace the default.

Application integration Solr search client case

The configuration of spring boot is centralized (it can be split into different configuration files). Therefore, add the following configuration in the application.properties file:

Use spring data Solr, similar to spring data JPA, to configure @ beans to accept ZK server related properties (the user-defined configuration method can directly use the default method)

Configure solrserver service. The specific code is as follows:

Test Solr query. The specific code is as follows:

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>