When solr4.10 has been installed, multi-core mode;
1. jar package to be prepared; database driver jar package mysql-connector-java-5.1.17-bin.jar, solr-dataimporthandler-4.10.0.jar;
Introduction In solrconfig. xml
<Lib dir = "F:/solrhome/multicore/lib" RegEx = ". * \. Jar"/>
2. Add the request processing class to the configuration file F: \ solrhome \ multicore \ core1 \ conf \ solrconfig. xml and load the configuration of the data source;
<requestHandler name = "/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"> <lst name ="defaults"> <str name = "config">data-config.xml </str> </lst> </requestHandler>
3. Configure the data source, new file F: \ solrhome \ multicore \ core1 \ conf \ data-config.xml
The configuration is as follows:
<dataConfig><dataSource password="root" user="root" url="jdbc:mysql://127.0.0.1:3306/jiaju" driver="com.mysql.jdbc.Driver" type="JdbcDataSource"/><document><entity query="select aid,title,author from article" name="article"> </entity></document></dataConfig>
4. Configure the fields and the Chinese word divider. In F: \ solrhome \ multicore \ core1 \ conf \ schema. xml
<schema version="1.1" name="example core one"><fieldtype name="string" omitNorms="true" sortMissingLast="true" class="solr.StrField"/><fieldType name="int" omitNorms="true" class="solr.TrieIntField" positionIncrementGap="0" precisionStep="0"/><fieldType name="long" class="solr.TrieLongField" positionIncrementGap="0" precisionStep="0"/><fieldType name="text" class="solr.TextField"><analyzer class="org.wltea.analyzer.lucene.IKAnalyzer"/></fieldType><!-- general --><field name="aid" required="true" stored="true" indexed="true" type="int"/><field name="title" stored="true" indexed="true" type="text"/><field name="author" stored="true" indexed="true" type="string"/><field name="_version_" stored="true" indexed="true" type="long"/><!-- field to use to determine and enforce document uniqueness. --><uniqueKey>aid</uniqueKey><!-- field for the QueryParser to use when an explicit fieldname is absent --><defaultSearchField>title</defaultSearchField><!-- SolrQueryParser configuration: defaultOperator="AND|OR" --><solrQueryParser defaultOperator="OR"/></schema>
5. Start tomcat, http: // localhost: 8983/SOLR/#/core1/dataimport // dataimport, select entity article, and execute. The result is as follows; this indicates that the database data is successfully indexed;
?
SOLR study notes -- dataimport