我需要微调搜索相关性和权重,因为返回的结果如下:
请求处理程序的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参数中删除内容^1的权重,那么相关性搜索和标题搜索工作得很好。得到预期的结果。
但是,如果我在Solr qf中保持内容^1的权重,那么一切都会出错。
问题可能与此有关,但不确定:
在Solr模式中,我的内容类型如下:
type="text_en_splitting"此字段类型应用了此筛选器:
<filter class="solr.PorterStemFilterFactory"/>在solr控制台中使用索引和查询值运行分析器时:一战完整单元
我可以看到,当它到达上面的过滤器时,值是:
first world war complet unit 'e‘从’完整‘字中省略了。
这里是solr中的响应片段,当'content^1‘在qf:中时
"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"
}的进一步发现:
当使用查询“世界大战”进行搜索时,“war”这个词的权重很大,因为它在前几个列表附件中发现了很多次。如果“战争”这个词是一个单独的词,或者是另一个词的一部分,那么这个分数就会得到提升。例如,“战争”和“小心”。
当“war”被发现为一个完整的词时,我只需要提高内容评分,而如果在其他词中发现了“war”,则不要做任何事情。希望这是合理的。
发布于 2015-04-23 15:13:05
这个问题的最终解决方案是用
sort=scoreA desc代替sort=score desc&boost=scoreA。这使用scoreA的boost值作为Solrscore的乘数,然后使用score进行排序,其中考虑到Solr自身的相关性数学和boost值。最终得出这一结论的最初答案和对话如下。
听起来你对其他字段的相对权重很满意,但即使权重较低,内容与其他字段相比也太相关了。
最有可能的解决方案是调整权重,要么降低内容的权重,要么提高其他字段的权重。也许content^0.1会给你你想要的结果。如果包含内容字段的唯一目的是在更重要的地方找不到匹配项,那么设置极低的相对权重将确保“内容”匹配永远不会超过其他字段中的匹配。
总的来说,我发现solr.explain.pl是调试Solr相关性的一个有用工具。它从已激活可选关联解释输出的测试Solr查询中获取查询结果,并给出如何确定每个结果文档的相关性的图形表示。它不能很好地处理具有自己的逻辑运算符的复杂查询,但是对于一个简单的测试查询,它可以很大程度上帮助您理解关联顺序是如何确定的,这样您就可以适当地调整它。
编辑:现在您已经添加了响应片段,我注意到您正在使用q.op=AND,但这是标准查询分析器的一个特性。由于您使用的是扩展Dismax查询分析器,所以应该使用mm (最小匹配)参数。mm=100%相当于Dismax和Extended查询解析器的q.op=AND。我不知道这是否与你的问题有关,但有可能是这样。
https://stackoverflow.com/questions/29821956
复制相似问题