SOLR study notes -- dataimport

Source: Internet
Author: User
Tags solr

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

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.