lucene - Index Mysql database using Data Import Handler in Solr -
i want index mysql database in solr using data import handler.
i have made 2 tables. first table holds metadata of file.
create table filemetadata ( id varchar(20) primary key , filename varchar(50), path varchar(200), size varchar(10), author varchar(50) ) ; +-------+-------------+---------+------+---------+ | id | filename | path | size | author | +-------+-------------+---------+------+---------+ | 1 | abc.txt | c:\files| 2kb | eric | +-------+-------------+---------+------+---------+ | 2 | xyz.docx | c:\files| 5kb | john | +-------+-------------+---------+------+---------+ | 3 | pqr.txt |c:\files | 10kb | mike | +-------+-------------+---------+------+---------+
the second table contains "favourite" info particular file in above table.
create table filefav ( fid varchar(20) primary key , id varchar(20), favouritedby varchar(300), favouritedtime varchar(10), foreign key (id) references filemetadata(id) ) ; +--------+------+-----------------+----------------+ | fid | id | favouritedby | favouritedtime | +--------+------+-----------------+----------------+ | 1 | 1 | ross | 22:30 | +--------+------+-----------------+----------------+ | 2 | 1 | josh | 12:56 | +--------+------+-----------------+----------------+ | 3 | 2 | johny | 03:03 | +--------+------+-----------------+----------------+ | 4 | 2 | sean | 03:45 | +--------+------+-----------------+----------------+
here "id' foreign key. second table showing person has marked document his/her favourite. eg file abc.txt represented id = 1 has been marked favourite (see column favouritedby) ross , josh.
i want index the files follows:
each document should have following fields
id - taken first table filemetadata filename - taken first table filemetadata path - taken first table filemetadata size - taken first table filemetadata author - taken first table filemetadata favouritedby - field should contain names of people table 2 filefav (from favouritedby column) particular file.
eg after indexing doc 1 should have
id = 1 filename = abc.txt path = c:\files size = 2kb author = eric favourited - ross , josh
how achieve this?
i have written data-config.xml (which not giving desired result) follows
<dataconfig> <datasource type="jdbcdatasource" driver="com.mysql.jdbc.driver" url="jdbc:mysql://localhost:3306/test" user="root" password="root" /> <document name="filemetadata"> <entity name="restaurant" query="select * filemetadata"> <field column="id" name="id" /> <entity name="filefav" query="select favouritedby filefav id=${filemetadata.id}"> <field column="favouritedby" name="favouritedby1" /> </entity> <field column="filename" name="name1" /> <field column="path" name="path1" /> <field column="size" name="size1" /> <field column="author" name="author1" /> </entity> </document> </dataconfig>
can explain how achieve this?
Comments
Post a Comment