tomcat - Query with q=*:* && q={keyword} && q=field:{keyword} in solr 4.9 -


  • i've found apache solr, , after installed apache solr tomcat successfully. , began use apache solr search.
  • but had problem results of apache solr.
  • when query field same as: title: love, , url same as:
    • http://my_ip:8080/solr/music/select?q=title%3a+love&wt=json&indent=true .
    • apache solr returned a lot of results title match word love.
  • the problem here if query same as: love, , url same as:
    • http://my_ip:8080/solr/music/select?q=love&wt=json&indent=true
    • apache solr didn't return results.

i want ask whyq=love didn't return results ? hope can me. thank much.

this schema.xml file:

<schema name="example" version="1.5"> <field name="_version_" type="long" indexed="true" stored="true"/> <field name="_root_" type="string" indexed="true" stored="false"/> <field name="id" type="string" indexed="true" stored="true" required="true" multivalued="false" /> <field name="title" type="text_vi" indexed="true" stored="true"/> <field name="text" type="text_general" indexed="true" stored="false" multivalued="true"/> <field name="type_music" type="text_vi" indexed="true" stored="true"/>  <dynamicfield name="*_i"  type="int"    indexed="true"  stored="true"/> <dynamicfield name="*_is" type="int"    indexed="true"  stored="true"  multivalued="true"/> <dynamicfield name="*_s"  type="string"  indexed="true"  stored="true" /> <dynamicfield name="*_ss" type="string"  indexed="true"  stored="true" multivalued="true"/> <dynamicfield name="*_l"  type="long"   indexed="true"  stored="true"/> <dynamicfield name="*_ls" type="long"   indexed="true"  stored="true"  multivalued="true"/> <dynamicfield name="*_t"  type="text_general"    indexed="true"  stored="true"/> <dynamicfield name="*_txt" type="text_general"   indexed="true"  stored="true" multivalued="true"/> <dynamicfield name="*_en"  type="text_en"    indexed="true"  stored="true" multivalued="true"/> <dynamicfield name="*_b"  type="boolean" indexed="true" stored="true"/> <dynamicfield name="*_bs" type="boolean" indexed="true" stored="true"  multivalued="true"/> <dynamicfield name="*_f"  type="float"  indexed="true"  stored="true"/> <dynamicfield name="*_fs" type="float"  indexed="true"  stored="true"  multivalued="true"/> <dynamicfield name="*_d"  type="double" indexed="true"  stored="true"/> <dynamicfield name="*_ds" type="double" indexed="true"  stored="true"  multivalued="true"/>  <!-- type used index lat , lon components "location" fieldtype --> <dynamicfield name="*_coordinate"  type="tdouble" indexed="true"  stored="false" />  <dynamicfield name="*_dt"  type="date"    indexed="true"  stored="true"/> <dynamicfield name="*_dts" type="date"    indexed="true"  stored="true" multivalued="true"/> <dynamicfield name="*_p"  type="location" indexed="true" stored="true"/>  <!-- trie-coded dynamic fields faster range queries --> <dynamicfield name="*_ti" type="tint"    indexed="true"  stored="true"/> <dynamicfield name="*_tl" type="tlong"   indexed="true"  stored="true"/> <dynamicfield name="*_tf" type="tfloat"  indexed="true"  stored="true"/> <dynamicfield name="*_td" type="tdouble" indexed="true"  stored="true"/> <dynamicfield name="*_tdt" type="tdate"  indexed="true"  stored="true"/>  <dynamicfield name="*_c"   type="currency" indexed="true"  stored="true"/>  <dynamicfield name="ignored_*" type="ignored" multivalued="true"/> <dynamicfield name="attr_*" type="text_general" indexed="true" stored="true" multivalued="true"/>  <dynamicfield name="random_*" type="random" /> <uniquekey>id</uniquekey>  <fieldtype name="string" class="solr.strfield" sortmissinglast="true" />  <!-- boolean type: "true" or "false" --> <fieldtype name="boolean" class="solr.boolfield" sortmissinglast="true"/> <fieldtype name="int" class="solr.trieintfield" precisionstep="0" positionincrementgap="0"/> <fieldtype name="float" class="solr.triefloatfield" precisionstep="0" positionincrementgap="0"/> <fieldtype name="long" class="solr.trielongfield" precisionstep="0" positionincrementgap="0"/> <fieldtype name="double" class="solr.triedoublefield" precisionstep="0" positionincrementgap="0"/> <fieldtype name="tint" class="solr.trieintfield" precisionstep="8" positionincrementgap="0"/> <fieldtype name="tfloat" class="solr.triefloatfield" precisionstep="8" positionincrementgap="0"/> <fieldtype name="tlong" class="solr.trielongfield" precisionstep="8" positionincrementgap="0"/> <fieldtype name="tdouble" class="solr.triedoublefield" precisionstep="8" positionincrementgap="0"/> <fieldtype name="date" class="solr.triedatefield" precisionstep="0" positionincrementgap="0"/> 

and solrconfig.xml file:

<lucenematchversion>4.9</lucenematchversion> <lib dir="../../../contrib/analysis-extras/lib" regex=".*\.jar" /> <lib dir="../../../contrib/extraction/lib" regex=".*\.jar" /> <lib dir="../../../dist/" regex="solr-cell-\d.*\.jar" /> <lib dir="../../../contrib/clustering/lib/" regex=".*\.jar" /> <lib dir="../../../dist/" regex="solr-clustering-\d.*\.jar" /> <lib dir="../../../contrib/langid/lib/" regex=".*\.jar" /> <lib dir="../../../dist/" regex="solr-langid-\d.*\.jar" /> <lib dir="../../../contrib/velocity/lib" regex=".*\.jar" /> <lib dir="../../../dist/" regex="solr-velocity-\d.*\.jar" /> <lib dir="../../../contrib/dataimporthandler/lib" regex=".*\.jar" /> <lib dir="/home/my_name/apache_solr/apache-tomcat-8.0.24/dist" regex="solr-dataimporthandler-4.9.0.jar" /> <lib dir="/home/my_name/apache_solr/apache-tomcat-8.0.24/dist" regex="solr-dataimporthandler-extras-4.9.0.jar" /> <lib dir="../../../lib" regex="mysql-connector-java-5.1.31-bin.jar" /> 

and data-config.xml file:

<dataconfig> <datasource type="jdbcdatasource"  driver="com.mysql.jdbc.driver" url="jdbc:mysql://127.0.0.1/sieunhac_development"  user="root"  password=""/> <document name="musics"> <entity name="musics" pk="id"   query="select p.id, lcase(p.title) title, birthday_singer, p.type_music musics p order updated_at desc;">   <field column="id" name="id" template="id"/>   <field column="title" name="title"/>    <field name="type_music" column="type_music" /> </entity> </document> </dataconfig> 

if @ solrconfig.xml file, see /select requesthandler configured default search field as:

<lst name="defaults">   <str name="df">name</str> </lst> 

here, can put field want example:

<lst name="defaults">   <str name="df">title</str> </lst> 

you can see topic this subject , solr documentation.

update

to answer comment, in schema.xml, can create new field:

<field name="searchable_field" type="text_general" indexed="true" stored="true"  multivalued="true" /> 

after that, can copy fields want in new field:

<copyfield source="title" dest="searchable_field"/> <copyfield source="author" dest="searchable_field"/> <copyfield source="production" dest="searchable_field"/> 

and finish, have put new field in solrconfig.xml:

<lst name="defaults">   <str name="df">searchable_field</str> </lst> 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -