SOLR 5.3 Import SQL Server data

Source: Internet
Author: User
Tags solr

I have an article in front of the SOLR configuration, which is not discussed here, the following configuration is in SOLR has been successfully integrated into the premise of Tomcat.

go to the chase,

1, modify the Solr-data-config. XML file with the following content:(PS: This article creates an index from the users table of the SSH database in SQL Server database, and its users table has id,name,pwd three fields, all of which are varchar type. Schema.xml file We type with string type)

<dataConfig>
<datasource password= "1234" user= "sa" url= "jdbc:sqlserver://127.0.0.1:1433;databasename=ssh" driver= " Com.microsoft.sqlserver.jdbc.SQLServerDriver "/>
<document name= "Info" pk= "id" >
<entity name= "Zpxx" transformer= "Clobtransformer" pk= "id"
query= "SELECT [Id],[name] as name from [SSH]. [dbo]. [Users] "
deltaimportquery= "SELECT [Id],[name] as name from [SSH]. [dbo]. [Users] where [publishdate] > ' ${dataimporter.last_index_time} ' "
deltaquery= "SELECT ID from [SSH]. [dbo]. [Users] where [publishdate] > ' ${dataimporter.last_index_time} ' ">
<field name= "id" column= "id"/>
<field name= "name" column= "name"/>
<field name= "pwd" column= "pwd"/>
</entity>
</document>
</dataConfig>

which  :

query is the SQL that gets all the data (SOLR gets those data from SQL), and multiple columns

deltaimportquery is the SQL used when retrieving incremental data (database additions to SOLR data), multiple columns

Deltaquery is to obtain the PK of SQL (the database new data is, append to SOLR data when the condition, according to ID, condition is last acquired time, ${dataimporter.last_index_time, last acquired time}), a column

2, modify schema.xml file declaration Field,field name should be the same as the SQL query result set column name;

<--ZX Configuring the SSH library field--
<field name= "id" type= "string" indexed= "true" stored= "true" multivalued= "false" required= "true"/>
<field name= "Name" type= "string" indexed= "true" stored= "true" multivalued= "false"/>
<field name= "pwd" type= "string" indexed= "true" stored= "true" multivalued= "false"/>

3, enter the SOLR management interface, command select Full-import all import, entity needs to import entities , that is, which SQL to configure, click Execute to perform the import, If there is a lot of data, you need to lead a period of time, occasionally point to refresh status refreshed, to see if the import is complete, after the import will tell you how much data imported, how much time. (because I will not paste the picture, bring inconvenience, please understand);

SOLR 5.3 Import SQL Server data

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.