Apache solr (2), apachesolr

Source: Internet
Author: User
Tags apache solr solr

Apache solr (2), apachesolr

In the previous article, I tried to install and configure solr and how to search for solr, today, I tried to connect solr to the MySQL database (only a single table, one-to-many, and many-to-many have yet to be studied)

1. MySQL directory structure

 

2. Create a New democore

3. Create a new core and field on the solr Server http: // localhost: 8983/solr visualization page. The fields of the field and the MySQL Database correspond one to one.

 

4. Configure solrconfig. xml, the data-config.xml is configured in our defined core, where the data-config.xml file is used to define the soling between solr and MySQL, where it uses a relative path, that is, with solrconfig. xml is in the same directory.

<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">    <lst name="defaults">         <str name="config">data-config.xml</str>    </lst></requestHandler>

  

 

<?xml version='1.0' encoding='utf-8'?><dataConfig>      <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://127.0.0.1:3306/solrdemo" user="root" password="" batchSize="-1"/>        <document name="democore">          <entity name="democore" pk="id" query="select * from democore">            <field column="id" name="id"/>            <field column="name" name="name"/>            <field column="number" name="number"/>          </entity>        </document></dataConfig>

  

 

5. Import the corresponding jar package to the corresponding directory.

 

6. import data on the Visual Interface

 

7. The data query shows that the import is successful.

 

Note: I was just getting started with solr, and the information I read on the Internet is also uneven. I don't know where to start, but I have to try a demo myself. If there is something wrong with it, please correct it. Thank you. Or where can I find something wrong? You have taken a detour. Please forgive me!

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.