php - How to run a sql query in solr -
ok have install solr , index database 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 users;" /> <field column="id" name="id" /> <field column="name" name="name" /> </document> </dataconfig>
which returns rows of database table users.
problem 1 :
but should if want search 'rakesh shetty' , should return result "rakesh vasant shetty" ?
i have tried <entity name="users" query="select id,name users name '%rakesh shetty%' ;" />
returns empty result.
problem 2 :
also, how can make search query dynamic ? mean there form search textbox , should query solr ? using php , solr 5.1.0.
thanks in advance.
try withe 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>
Comments
Post a Comment