【问题标题】:What I need to write in schema.xml for searching in two or more fields in Solr?我需要在 schema.xml 中写什么来搜索 Solr 中的两个或多个字段?
【发布时间】:2013-05-08 11:43:49
【问题描述】:

我是 Solr 的新手。 我已经将 3 个字段从 MySql 索引到 solr。 身份证,名字,姓氏。 我想搜索 first_name 和 last_name。 我在 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"/>

我必须在这里写的内容是先在 first_name 中搜索,然后在 last_name 中搜索。 我必须在哪里优先考虑领域? 请帮帮我。

【问题讨论】:

    标签: php mysql apache solr


    【解决方案1】:

    您必须在查询中定义它。我建议您为此使用 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/

    【讨论】:

    • 我必须在 solconfig.xml 中添加这个?
    • requestHandler 的一个例子。您可以定义自己的类似内容,以便定义搜索中字段的相关性以及在多个字段中进行搜索的可能性
    猜你喜欢
    • 2011-11-06
    • 2012-10-21
    • 2013-12-14
    • 1970-01-01
    • 2012-02-06
    • 1970-01-01
    • 1970-01-01
    • 2019-12-20
    • 2011-12-26
    相关资源
    最近更新 更多