Development of Data Solr search engine based on SpringBoot

About Apache Solr

Solr is an open source search server based on Lucene Java, which is easy to add to Web applications. Solr provides layer search (i.e., statistics), hit and eye-catching display, and supports multiple output formats (including XML/XSLT and JSON). It is easy to install and configure, and comes with an HTTP based management interface. You can use Solr's excellent basic search function, or you can extend it to meet the needs of the enterprise. Solr features include:

Supports English, German, China, Japan, France and many major languages

The relationship between Apache Solr and Lucene

Solr and Lucene do not compete against each other. On the contrary, Solr depends on Lucene, because the core technology of Solr is implemented by Apache Lucene. In short, Solr is the server of Lucene. It should be noted that Solr does not simply encapsulate Lucene. Most of the functions it provides are different from Lucene.

Apache Solr related directory description

Structure description of Solr package

bin: solr related running script

docs: relevant API reference documents, wiki materials, etc

licenses: solr related certificates are stored

contrib: jar package of solr related extension

dist: store the JAR file, WAR file and the JAR file that Solr relies on after Solr build.

example: is an installed Jetty middleware, including some sample data and Solr configuration information.

example/etc: Jetty's configuration file.

example/multicore: used to place multiple Solr home directories when Slor multicore is installed.

example/solr: the home directory of Solr by default.

example/example-DIH: example of database as index data source

example/webapps: Solr's WAR file is deployed here.

src: Solr related source code.

src/java: the Java source of Slor.

src/scripts: some Unix bash shell scripts that are useful when large products are released.

src/solrj: the Java client of Solr.

src/test: Solr's test source and test file.

src/webapp: Solr web management interface. The Jsp files of the management interface are all placed under web/admin /. You can modify these files according to your needs.

Solr home directory structure description

bin: it is recommended to put the cluster replication script in this directory.

conf: place the configuration file.

conf/schema.xml: the indexed schema contains the field type definition and its associated parsers.

conf/solrconfig.xml: This is Solr's main configuration file.

conf/xslt: contains many xslt files, which can convert the query results of Solr's XML to a specific format, such as Atom/RSS.

Data: place index data generated by Lucene.

lib: place optional JAR files, such as plug-ins for Slor extension, which will be loaded when Solr starts.

Create a solr home directory (the user can decide according to the operating system), and copy all the files except bin in the solr compression package under the example directory D: \ solr home directory, as shown in the figure:

Open web.xml under Tomcat/webapps/solr/WEB-INF and add the following configuration content (the content is commented out in the initial state):

<env-entry>
<env-entry-name>solr/home</env-entry-name>
<env-entry-value>D:/solr_home</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
Change the content in < env entry value > to your Solr home path, here is D: / Solr? Home
This configuration is mainly to establish the relationship between tomcat and solr. Its function is to let tomcat find the solr directory you have configured.

Start tomcat and input the following URL from the address bar: http://localhost:8080/solr, the following interface will appear:

Chapter 2: Apache Solr imports data from MySQL database

Import solr's own data import package and put it into lib under Web inf of solr project in tomcat
Add the Lib package in the directory of collection1, and copy the package needed for data import to lib
Including mysql package

Their common feature is to provide us with framework code. spring Data can automatically create the implementation class and custom query of entity dao without us defining it, which simplifies the operation of dao layer.

It is worth noting that if you use the Spring Data Solr operation, you must add a label to the entity class corresponding to Solr