Ok now I have successfully install solr and index by database with following structure : DB_NAME - solr, Table - users
my db-data-config.xml file :
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/solr"
user="root"
password="" />
<document>
<entity name="users" query="select id,name from users;" />
<field column="ID" name="id" />
<field column="NAME" name="name" />
</document>
</dataConfig>
Which returns rows of database table users.
Problem 1 :
But what should I do if I want to search like 'Rakesh Shetty' and it should return result "Rakesh Vasant Shetty" ?
I have tried <entity name="users" query="select id,name from users where name like '%Rakesh Shetty%' ;" />
but it returns empty result.
Problem 2 :
Also, how can I make this search query dynamic ? I mean there will be a form with search textbox and it should query to solr ? I am using php and solr 5.1.0.
Thanks in advance.
try withe the below schema.
<schema name="simple" version="1.5">
<types>
<fieldType name="text" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" preserveOriginal="1" splitOnCaseChange="1"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="0"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
</types>
<fields>
<field name='id' type='int' required='true' indexed="true" stored="true"/>
<field name='name' type='text' required='true' indexed="true" stored="true"/>
</fields>
<uniqueKey>id</uniqueKey>
<defaultSearchField>name</defaultSearchField>
<solrQueryParser defaultOperator='OR' />
</schema>