Apache SOLR (ii)

Source: Internet
Author: User
Tags apache solr solr

The previous article tried to install and configure SOLR, and how SOLR retrieved it today, trying to simply connect SOLR to the MySQL database (only to try out single table, one-to-many, and many-to-many, yet to be researched)

1. mysql directory structure

2. Create a new Democore

3. The field field one by one for the new core and Field,field and MySQL database on the SOLR server HTTP://LOCALHOST:8983/SOLR visualization page corresponds to

4. Configuring Solrconfig.xml, Data-config.xml is configured in our defined core, where the Data-config.xml file is used to define the mapping relationship between SOLR and MySQL, using a relative path, which is the same directory as Solrconfig.xml.

<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. Visual interface to import data

7, query data display import success

Note: I have just started to contact SOLR soon, the information on the Internet is also uneven, do not know where to start, can only try to do a small demo line. If there is a wrong place to write, please help me correct, thank you. or where I have the wrong understanding of the place, to you take a detour, please understand!

Apache SOLR (ii)

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.