- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Created on 08-18-2016 05:43 AM - edited 08-17-2019 10:49 AM
Solr indexing the MySQL database table on HDP 2.5 Tech Preview:
Solr version used: solr 4.9.0
Step1: Downloaded the solr 4.9.0.zip from
https://archive.apache.org/dist/lucene/solr/4.9.0/
Step2: Extract the file:
Step3: modify the solrconfig.xml, schema.xml and add the db-data-config.xml at
Step4: add the jar at this location
- a.vi solrconfig.xml: add these lines in between the config tags.
<lib dir="../../../contrib/dataimporthandler/lib/" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-dataimporthandler-\d.*\.jar" />
<lib dir="../../../lib/" regex="mysql-connector-java-5.0.8-bin.jar" />
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">db-data-config.xml</str>
</lst>
</requestHandler>
- b.vi schema.xml add the below line:
<dynamicField name="*_name" type="text_general" multiValued="false" indexed="true" stored="true" />
- c.Create a file called db-data-config.xml at the same path later in this session I would create a database employee in mysql server add these
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/employees"
user="root"
password="hadoop" />
<document>
<entity name="id" query="select emp_no as 'id', first_name, last_name from employees limit 1000;" />
</document>
</dataConfig>
After this is complete run the below command (d) to start solr and check if solr is up and running at url below: 8983 is the default port of solr
d.java –jar start.jar
- e.select the core selector as collection1.
- f.Click on Data Import, expand configuration and check if its pointing to our db-data-config.xml file we created.
- g.After the completion of Step5 below click on execute on the page.
Step5:
Setting up database:
Import an already available database into Mysql:
- Ref: https://dev.mysql.com/doc/employee/en/employees-installation.html
- shell> tar -xjf employees_db-full-1.0.6.tar.bz2
- shell> cd employees_db/
- shell> mysql -t < employees.sql
- With this installation of employees db in mysql is complete.
Step6: With this our indexing is complete using Solr.
To do:
I will try indexing the tables in Mysql using latest version of Solr.
Reference: http://blog.comperiosearch.com/blog/2014/08/28/indexing-database-using-solr/
Hope this helps….
Thanks,
Sujitha