Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of importing data from Mysql by Solr6.3 Service

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "the method of importing data from Mysql by Solr6.3 service". In the daily operation, I believe that many people have doubts about the method of importing data from Mysql by Solr6.3 service. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to import data from Mysql by Solr6.3 service". Next, please follow the editor to study!

After installing the solr6.3 service, I installed it on the centos7 system, in the / opt directory

Step 1:

Create a core, using hubin as an example

Step 2:

Copy the jar package (mysql driver package mysql-connector-java-5.1.38.jar) required by mysql and the solr-dataimporthandler-6.3.0.jar and solr-dataimporthandler-extras-6.3.0.jar under solr-6.3.0/dist to the project / opt/solr-6.3.0/server/solr-webapp/webapp/WEB-INF/lib/. Then add it to the solrconfig.xml file (that is, configure the jar package in WEB-INF\ lib to the project. I use the absolute address here. This code is about 70 lines of solrconfig.xml, with a similar pile of code in front of it. )

Step 3:

Create a new table in MYSQL. What I use here is the Navicat management tool to create. The table name here is goods. The fields are shown in the following figure:

Step 4:

In solrconfig.xml

Data-config.xml

Then create a new data-config.xml file under conf. The contents are as follows:

Description:

DataSource is the database data source. Entity is the corresponding entity of a table, contention is the primary key, and query is the query statement. Field corresponds to a field, column is the column name in the database, and the following name attribute corresponds to the name of Solr's Filed. Where solrdata is the database name and goods is the table name.

Where deltaQuery is an incremental index, the principle is to query the ID number of all the data that need to be imported incrementally from the database according to the SQL statement specified by deltaQuery. Then the data of all these ID is returned according to the SQL statement specified by deltaImportQuery, that is, the data to be processed for this incremental import. The core idea is to record the id to be indexed and the time of the last index through the built-in variables "${dih.delta.id}" and "${dataimporter.last_index_time}".

Finally, configure the field information in managed-schema under the conf file:

Where id,name,number,updateTime is the database field mentioned above. The following three field cannot be deleted by the system itself, otherwise it will run incorrectly.

Step 5:

Start tomcat and enter the http://127.0.0.1:8080/solr/index.html path in URL. Select Core admin and enter the following settings:

Select the newly added goods entity for indexing operation: we can select full-import or delta-import (incremental index). To select an incremental index, you need to uncheck the clean, otherwise it will be cleared. The original intention of the incremental index is to re-index the newly added or modified records, which will be appended to the original index file. When we choose full-import, it is best to empty the original index file and re-index it.

The success of the index is as follows:

Test with query, enter sa to find out the sa

The MYSQL database has been successfully configured. If there are any problems in the configuration process, please refer to my code that has been successfully configured:

The above default management of schema in PS:solr-5.0 is to use managed-schema, which cannot be modified manually. You need to use the API operation of Schema Restful. If you want to modify the configuration manually, make a copy of managed-schema and change it to schema.xml, and modify it in solrconfig.xml as follows:

At this point, the study on "how Solr6.3 services import data from Mysql" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report