通过顶部指定的搜索词提升结果

发布于 2024-12-09 11:03:01 字数 448 浏览 0 评论 0原文

我正在使用 apache solr 3.1 和 drupal

如何将搜索字段中指定的结果提升到顶部?

在搜索字段中的示例,如果用户输入继续,solr会显示顶部具有连续性的文档,下面显示继续的文档,我想显示连续高于连续性

http://localhost:8983/ solr/select/?q=继续&qf=标题&fl=标题%20score&bq=标题:继续^10.0

I'm using apache solr 3.1 with drupal

How can boost result on top which is specified in search field?

Example in search field, if user enters continuing, solr shows the document which have Continuity on top and the one with continuing below, i want to show the one with continuing above than the Continuity

http://localhost:8983/solr/select/?q=continuing&qf=title&fl=title%20score&bq=title:continuing^10.0

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

双马尾 2024-12-16 11:03:01

看来您在过滤器链中有词干分析器,因此连续性和连续性并映射到相同的根并且将被同等对待。

您想要检查您正在使用的词干分析器,并希望根据您的需要获得一个。默认的波特词干分析器非常激进,您可能需要一个不太激进的选项。

Solr 目前不会将精确匹配提升到比生成相同根的其他项更高的水平。
一种选择是在架构中包含两个字段。
词干 (title_stemmed) 和非词干版本(标题 - 没有词干过滤器)

示例 -

schema.xml -

<!-- Without Porter Stemmer -->
<fieldType name="text_non_stemmed" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
    <analyzer type="index">
        <tokenizer class="solr.WhitespaceTokenizerFactory
        <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>
    <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>
</fieldType>

<!-- With Porter Stemmer -->
<fieldType name="text" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
    <analyzer type="index">
        <tokenizer class="solr.WhitespaceTokenizerFactory
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.PorterStemFilterFactory"/>
    </analyzer>
    <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.PorterStemFilterFactory"/>
    </analyzer>
</fieldType>

<field name="title" type="text" indexed="true" stored="true" termVectors="false" omitNorms="false"/>    
<field name="title_non_stemmed" type="text_non_stemmed" indexed="true" stored="true" termVectors="false" omitNorms="false"/>

<copyField source="title" dest="title_non_stemmed"/>

您可以对字段进行加权 -

solrconfig.xml - 修改默认请求处理程序

<requestHandler name="search" class="solr.SearchHandler" default="true">
 <lst name="defaults">
   <str name="echoParams">explicit</str>
   <str name="defType">dismax</str>
   <str name="qf">
      title_non_stemmed^1 title^0.8
   </str>
   <str name="q.alt">*:*</str>
   <str name="rows">10</str>
   <str name="fl">*,score</str>
 </lst>
</requestHandler>

,以便精确匹配比非精确匹配产生更多分数匹配并且显得更高。

网址 -

http://localhost:8983/solr/select/?q=continuing

It seems you have stemmer in the filter chains, due to which continuing and Continuity and mapped to the same root and would be treated equal.

you want want to check for the stemmer you are using and want to get one depending upon your needs. The default porter stemmer is very agressive, and you may want an less agressive options.

Solr does not currently boost the exact match higher than the other terms which generated the same root.
One option would be to have two fields in your schema.
Stemmed (title_stemmed) and a Non Stemmed version (title - without the stemming filter)

example -

schema.xml -

<!-- Without Porter Stemmer -->
<fieldType name="text_non_stemmed" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
    <analyzer type="index">
        <tokenizer class="solr.WhitespaceTokenizerFactory
        <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>
    <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>
</fieldType>

<!-- With Porter Stemmer -->
<fieldType name="text" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
    <analyzer type="index">
        <tokenizer class="solr.WhitespaceTokenizerFactory
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.PorterStemFilterFactory"/>
    </analyzer>
    <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.PorterStemFilterFactory"/>
    </analyzer>
</fieldType>

<field name="title" type="text" indexed="true" stored="true" termVectors="false" omitNorms="false"/>    
<field name="title_non_stemmed" type="text_non_stemmed" indexed="true" stored="true" termVectors="false" omitNorms="false"/>

<copyField source="title" dest="title_non_stemmed"/>

you can weight the fields -

solrconfig.xml - modify the default request handler

<requestHandler name="search" class="solr.SearchHandler" default="true">
 <lst name="defaults">
   <str name="echoParams">explicit</str>
   <str name="defType">dismax</str>
   <str name="qf">
      title_non_stemmed^1 title^0.8
   </str>
   <str name="q.alt">*:*</str>
   <str name="rows">10</str>
   <str name="fl">*,score</str>
 </lst>
</requestHandler>

so that the exact match produces more score than the non exact matches and appears higher.

URL -

http://localhost:8983/solr/select/?q=continuing
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文