【问题标题】:solr lucene apply bf only when query matches textsolr lucene 仅在查询匹配文本时应用 bf
【发布时间】:2015-02-27 11:19:27
【问题描述】:

当查询“来自 john 的电子邮件”与文本“一些其他包含来自 john 的电子邮件的文本”匹配时,查询中的每个单词都以这种精确格式存在于文本字段中:

只有那时我才需要应用 bf 函数。

是否可以使用 Solr 实现此规则/功能?

谢谢, 彼得

【问题讨论】:

  • 我不知道。您在使用 Solr 的地方有哪些应用程序层?例如当有 Java 客户端(使用 Solrj)时,如果查询中包含某些文本,添加 bf 将非常容易......
  • @cheffe 我正在从名为 CQ5 的 cms 系统调用 Solr。你能提供一个简单的例子来说明你将如何使用 Solrj 吗?
  • 为什么不使用词组提升?它与您需要做的非常接近,唯一的区别是在短语提升中,单词必须以相同的顺序出现。您只需要使用字段名称和每个字段的权重指定 pf 参数。

标签: solr lucene edismax


【解决方案1】:

我想是的,你只需要在你的 solrconfig.xml 中创建一个新的请求处理程序来应用该函数:

<requestHandler name="/match" class="solr.SearchHandler">
<lst name="defaults">
    <str name="echoParams">all</str>
    <str name="defType">edismax</str>
    <str name="rows">5</str>
    <str name="fl">*,score</str>
    <str name="bf">product(log(sum(popularity,1)),100)^20</str>
    <str name="boost">product(map(query($type1query),0,0,1,$type1boost),map(query($type2query),0,0,1,$type2boost),map(query($type3query),0,0,1,$type3boost),map(query($type4query),0,0,1,$type4boost),$typeboost)</str>
    <double name="typeboost">1.0</double>

    <str name="type1query">type:"type1"</str>
    <double name="type1boost">0.9</double>
    <str name="type2query">type:"type2"</str>
    <double name="type2boost">0.5</double>
    <str name="type3query">type:"type3"</str>
    <double name="type3boost">0.3</double>
    <str name="type4query">type:"type4"</str>
    <double name="type4boost">0.1</double>
    <str name="debugQuery">false</str>
    <str name="omitHeader">true</str> 
    <str name="wt">json</str> 
    <str name="indent">true</str> 
</lst>

并构建一个只匹配以下单词的查询:

http://localhost:8983/solr/collection1/match?q=*email from john

【讨论】:

    猜你喜欢
    • 2016-08-10
    • 1970-01-01
    • 1970-01-01
    • 2014-02-08
    • 2016-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多