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