Solr 5.3 import SQL Server Data

Source: Internet
Author: User
Tags solr

Solr 5.3 import SQL Server Data

I have explained the solr configuration in the previous article. As you can see, I will not talk about it here. The following configuration is done on the premise that solr has been successfully integrated into tomcat.

Go to the topic,

1. Modify solr-data-config. Xml file, the content is as follows: (PS: This article creates an index based on the users table of the SSH database in the sqlserver database. Its users table has three fields: id, name, and pwd, all are varchar type, schema. for the xml file, the type must be 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>

Where:

Query is an SQL statement that obtains all data (solr obtains the data from the SQL statement) and multiple columns.

DeltaImportQuery is an SQL statement used to obtain incremental data (data added to solr by the database), with multiple columns

DeltaQuery is the SQL statement used to obtain the primary key (new data in the database is the condition when the data is appended to solr. Based on the id, the condition is the last time the data is obtained, $ {dataimporter. last_index_time, last retrieved time}), one column

 

2. Modify the schema. xml file to declare the field. The field name should be the same as the column name of the SQL query result set;

<-- Zx configures the field of the SSH Library -->
<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. Go to the solr management interface, and select "full-import" for "command". The entity object to be imported, that is, the configured SQL, and click execute to execute the import, if there is a lot of data, you need to import it for a period of time. From time to time, click refresh status to refresh and check whether the import is complete. After the import is complete, the system will tell you how much data is imported and how long it takes.

Solr3.6.1 build an environment in Tomcat6

Tomcat-based Solr3.5 cluster deployment

Load Balancing for Solr clusters using Nginx on Linux

Install and use Solr in Linux

Deploy Solr 4 on Ubuntu 12.04 LTS through Tomcat

Solr implements Low Level query parsing (QParser)

Build a search Server Based on Solr 3.5

Solr 3.5 development and application tutorial PDF

Solr 4.0 deployment instance tutorial

Solr details: click here
Solr: click here

This article permanently updates the link address:

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.