【问题标题】:relevance by keyword solr关键词 solr 的相关性
【发布时间】:2017-11-14 13:48:53
【问题描述】:

我们如何根据关键字的位置对查询的结果进行排序?

我只在标签字段上开始搜索

当我有

  1. solr 搜索查询 titi
  2. titi 测试倾斜
  3. toto titi tata

我们应该设置什么参数来恢复这个订单?

  1. titi 测试倾斜
  2. toto titi tata
  3. solr 搜索查询 titi

我使用 Drupal 连接并向 solr 发送查询。

【问题讨论】:

  • 据我所知;你不能。术语的位置不用于评分(短语查询除外)。您可能必须编写一个自定义函数或记分器来实现这一点。一种“简单”的方法可能是遵循来自 lucidworks 的the payload tutorial,它使用附加到每个术语的有效负载来对该术语的重要性进行排名。您也许可以跳过有效负载并直接使用该位置..
  • @MatsLindh 我忘了指定我已经只在标签字段上运行了搜索
  • 我不确定这会如何改变任何事情。

标签: sorting solr drupal-7 relevance solr5


【解决方案1】:

如果您的域非常包含并且您知道例如您期望的标签大小,您可以使用复制字段和 dismax 查询解析器获得接近您想要的东西。 具体来说,您可以通过这种方式构建 N 个“copyfields”:

<field name="label" type="text_general" indexed="true" stored="true"/>
<field name="label_3" type="text_first_3" indexed="true" stored="true"/>
<field name="label_5" type="text_first_5" indexed="true" stored="true"/>
...
<fieldType name="text_first_3" class="solr.TextField" positionIncrementGap="100">
        <analyzer type="index">
            <tokenizer class="solr.WhitespaceTokenizerFactory"/>
            <filter class="solr.LimitTokenPositionFilterFactory"             maxTokenPosition="3" consumeAllTokens="false" />
</analyzer>
        <analyzer type="query">
            <tokenizer class="solr.StandardTokenizerFactory"/>
        </analyzer>
    </fieldType>

<fieldType name="text_first_5" class="solr.TextField" positionIncrementGap="100">
        <analyzer type="index">
            <tokenizer class="solr.WhitespaceTokenizerFactory"/>
            <filter class="solr.LimitTokenPositionFilterFactory"             maxTokenPosition="5" consumeAllTokens="false" />
</analyzer>
        <analyzer type="query">
            <tokenizer class="solr.StandardTokenizerFactory"/>
        </analyzer>
    </fieldType>
...
<copyField source="label" dest="label_3"/>
<copyField source="label" dest="label_5"/>

这要归功于限制令牌位置过滤器[1]。 然后您可以使用 edismax 指定不同的提升:

qf="label_3^5 label_5^2 label"

这里也讨论了这个问题 [2]。

这里提到了另一种方法[3]。

[1]https://lucene.apache.org/solr/guide/6_6/filter-descriptions.html#FilterDescriptions-LimitTokenPositionFilter

[2]https://issues.apache.org/jira/browse/SOLR-3925

[3]Solr - How to boost score for early matches?

【讨论】:

    猜你喜欢
    • 2018-09-19
    • 1970-01-01
    • 1970-01-01
    • 2017-04-22
    • 2014-12-09
    • 2017-06-20
    • 2015-06-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多