简体   繁体   中英

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

I'm new in Solr. I've indexed 3 fields from MySql to solr. Id, first_name, last_name. I want to search in first_name and last_name. In schema.xml I wrote:

<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. 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 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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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