Tuesday, 2 December 2014

Query with Solr and MySQL in JAVA



I have a MySQL DB indexed with Solr, and for my purpose I need to query the data inside this DB. I'd like to perform "soft" query, like every search engine on the web.


I'm trying to set two sample field inside schema.xml



<uniqueKey>organization_id</uniqueKey>

<field name="organization_id" type="string" indexed="true" stored="true" required="true"/>
<field name="name" type="string" indexed="true" stored="true"/>


This is my solrconfig.xml



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


And, finally, data-config.xml


<dataConfig> <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/organizations2" user="****" password="****" /> <document name="content"> <entity name="id" query="SELECT * FROM organization" deltaImportQuery="SELECT * FROM organization" deltaQuery="SELECT * FROM organization"> <field column="organization_id" name="organization_id" /> <field column="name" name="name" /> </entity> </document> </dataConfig>


It's possible to make classic query, with a similar organization name, and then return the correct company? I'm trying to search all day but no solution.


Thanks a lot


No comments:

Post a Comment