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)