Solr 搜索相关性提升和 bf 加权不适用于内容^1

Solr search relevance boost and bf weighting not working with content^1

我需要微调我的搜索相关性和权重,因为结果 returned 是:

Solr 请求处理程序的配置片段:

<requestHandler name="/select" class="solr.SearchHandler">
<lst name="defaults">
  <str name="defType">edismax</str>
  <str name="echoParams">explicit</str>
  <int name="rows">10</int>
  <str name="df">text</str>
  <str name="q.alt">*:*</str>
  <str name="q.op">AND</str>
  <str name="qf">title^15.0 description^9.0 categoryNames^3.0 authorName^1.0 content^1.0</str>
  <str name="boost">scoreA</str>
</lst>
<lst name="appends">
  <str name="fq">private:false</str>
  <str name="fq">deleted:false</str>
  <str name="fq">draft:false</str>
</lst>

Solr 架构片段:

<field name="content" type="text_en_splitting" indexed="true" stored="true" multiValued="true"/>

<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false"/>
<field name="type" type="string" indexed="true" stored="true"/>
<field name="title" type="text_en_splitting" indexed="true" stored="true"/>
<field name="description" type="text_en_splitting" indexed="true" stored="true"/>
<field name="url" type="string" indexed="false" stored="true"/>
<field name="authorId" type="long" indexed="true" stored="true"/>
<field name="authorName" type="text_en" indexed="true" stored="true"/>

  <copyField source="title" dest="text"/>
  <copyField source="description" dest="text"/>
  <copyField source="content" dest="text"/>

<fieldType name="text_en_splitting" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
  <analyzer type="index">
    <charFilter class="solr.HTMLStripCharFilterFactory"/>
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="lang/stopwords_en.txt"/>
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
    <filter class="solr.PorterStemFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="lang/stopwords_en.txt"/>
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
    <filter class="solr.PorterStemFilterFactory"/>
  </analyzer>
</fieldType>

twigkit 搜索查询:

<search:query var="query" type="all" parameters="*" resultsPerPage="18" sorts="-scoreA" fields="id,url,price,title,description,recommended,modifiedDate,downloadCount:field(downloadCount),ratingAverage:field(ratingAverage),ratingCount:field(ratingCount),scoreA:field(scoreA),scoreB:field(scoreB),viewCount:field(viewCount),authorName,authorId,content,categoryNames">
</search:query>

<search:response var="response" platform="${platform}" query="${query}"></search:response>

我目前的发现: 如果我从 Solr qf 参数中删除 content^1 权重,那么相关性搜索和标题搜索将完美运行。获得预期的结果。

但是,如果我在 Solr qf 中保留内容^1 权重,那么一切都会出错。

问题可能与此有关但不确定:

在 Solr 模式中,我的内容类型为:

type="text_en_splitting"

此字段类型应用了此过滤器:

<filter class="solr.PorterStemFilterFactory"/>

当运行 solr 控制台中的分析器具有索引和查询值时: 第一世界 war 完整单元

我可以看到当它到达上面的过滤器时,值为:

first world war complet unit 

从'complete'字中省略了'e'。

这是当 'content^1' 在 qf 中时 solr 中的响应片段:

"responseHeader": {
"status": 0,
"QTime": 187,
"params": {
  "lowercaseOperators": "true",
  "spellcheck": "true",
  "facet": "true",
  "sort": "scoreA desc",
  "indent": "true",
  "qf": "title^15.0 description^9.0 categoryNames^3.0 authorName^1.0 content^1",
  "spellcheck.collate": "true",
  "wt": [
    "json",
    "javabin"
  ],
  "hl": "true",
  "version": "2",
  "defType": "edismax",
  "rows": "18",
  "fl": "id,url,price,title,description,recommended,modifiedDate,downloadCount:field(downloadCount),ratingAverage:field(ratingAverage),ratingCount:field(ratingCount),scoreA:field(scoreA),scoreB:field(scoreB),viewCount:field(viewCount),authorName,authorId,content,categoryNames,score",
  "start": "0",
  "q": "world wars",
  "q.op": "AND",
  "_": "1429801074587",
  "facet.field": [
    "categories",
    "categoryRoot",
    "resourceTypes",
    "fileTypes",
    "recommended",
    "licence"
  ],
  "stopwords": "true"
}

进一步的发现:

在使用查询 'world war' 进行搜索时,词 'war' 的权重很高,因为它在前几个列表附件中出现了很多次。如果单词 'war' 单独作为一个单词或作为另一个单词的一部分被发现,那么分数似乎会得到提升。例如,'war' 和 'beware'。

我只需要在 'war' 作为一个完整的单词找到时提高内容分数,如果在其他单词中找到则不做任何事情。希望这是有道理的。

The final solution to this issue turned out to be instead of sort=scoreA desc to use sort=score desc&boost=scoreA. This uses the boost value of scoreA as a multiplier to the Solr score, then sorts using the score which takes into account Solr's own relevance math and the boost value. The original answer and the conversation that led to this conclusion follows.

听起来您对其他字段的相对权重很满意,但即使权重较低,与其他字段相比,内容也相关。

最可能的解决方案是调整权重,要么降低内容的权重,要么提高其他字段的权重。也许 content^0.1 会给你想要的结果。如果您包含内容字段的唯一目的是在更重要的地方找不到匹配项时在那里找到匹配项,那么设置一个极低的相对权重将确保 "content" 匹配项永远不会超过其他字段中的匹配项.

总的来说,我发现 solr.explain.pl 是调试 Solr 相关性的有用工具。它从您已激活可选相关性解释输出的测试 Solr 查询中获取查询结果,并为您提供有关如何为每个结果文档确定相关性的图形表示。它不能很好地处理具有自己的逻辑运算符的复杂查询,但是对于简单的测试查询,它可以帮助您理解相关顺序是如何确定的,以便您可以适当地调整它。


编辑:现在您已经添加了响应片段,我注意到您正在使用 q.op=AND,但这是 Standard Query Parser. Since you're using the Extended Dismax Query Parser, you ought to be using the mm (Minimum Match) 参数的一个功能。 mm=100% 相当于 Dismax 和扩展 Dismax 查询解析器的 q.op=AND。我不知道这是否与您遇到的问题有关,但可能是。