简体   繁体   English

我需要在schema.xml中编写什么内容才能在Solr中搜索两个或多个字段?

[英]What I need to write in schema.xml for searching in two or more fields in Solr?

I'm new in Solr. 我是Solr的新手。 I've indexed 3 fields from MySql to solr. 我已经将MySql的3个字段索引到solr。 Id, first_name, last_name. ID,名字,姓氏。 I want to search in first_name and last_name. 我想搜索名字和姓氏。 In schema.xml I wrote: 在schema.xml中,我写道:

<fields>
<field name="id" type="string" indexed="true" stored="true"/>
<field name="first_name" type="text_general" indexed="true" stored="true"/>
<field name="last_name" type="text_general" indexed="true" stored="true"/>
</fields>
<uniqueKey>id</uniqueKey>
<defaultSearchField>first_name</defaultSearchField>
<solrQueryParser defaultOperator="OR"/>

What I have to write here for searching first in first_name and after in last_name. 要在first_name中进行搜索,然后在last_name中进行搜索,我必须在此处编写。 Where I have to give priorities for fields? 我必须在哪里优先考虑领域? Please, help me. 请帮我。

You will have to define this on the query. 您将必须在查询上定义它。 I recomend you to use a requestHandler for this: 我建议您为此使用requestHandler:

<requestHandler name="bcn_jug_en" class="solr.SearchHandler" enable="true">
 <lst name="defaults">
   <str name="defType">edismax</str>
   <str name="qf">first_name^10 last_name^5</str>
   <str name="mm">100%</str>
</lst>

http://searchhub.org/2010/05/23/whats-a-dismax/ http://searchhub.org/2010/05/23/whats-a-dismax/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM