Solr停用词问题 - 文档不匹配

4

我正在使用solr-3.4,我的schema的一部分如下:

<fieldType name="text" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
    <analyzer type="index">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords_en.txt" enablePositionIncrements="true"/>
        <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="stopwords_en.txt" enablePositionIncrements="true"/>
        <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>

stopwords_en.txt包含:
a
an
and
are
as

等等……

现在,当我搜索“购买房屋”时,Solr不会返回文本为“购买一栋房屋”的文档。
同样,当我搜索“购买一栋房屋”时,Solr也不会返回文本为“购买房屋”的文档。

其中部分debugQuery内容是:

<str name="rawquerystring">cContent:"buy a house"</str>
<str name="querystring">cContent:"buy a house"</str>
<str name="parsedquery">PhraseQuery(cContent:"bui ? hous")</str>
<str name="parsedquery_toString">cContent:"bui ? hous"</str>

发现了类似(但不完全相同)的问题在这里
但是没有很好的答案来解决这个问题。

你有什么想法可以解决这个问题吗?或者说有什么地方做错了吗?


你能否前往Solr管理分析页面(http://localhost:8983/solr/admin/analysis.jsp?highlight=on),并发布“买房”索引和查询分析结果(检查详细输出)? - Romain Meresse
由于字符限制,无法在此处粘贴。但我已经将其放在这里(http://ameykpatil.weebly.com/solrimage.html) - ameykpatil
2个回答

3
您正在使用PhraseQuery进行搜索,因此“买房子”中的第一个例子不会匹配“买一栋房子”。如果在PhraseQuery中添加slop(cContent:“buy house”〜2),则还将获得匹配项。
对于第二种情况,尽管停用词被过滤掉了,但它仍然期望该位置上有某些内容,因此“买一栋房子”将匹配“买一所房子”,但不匹配“买房子”。也许slop也可以解决这个问题,但我不确定。

谢谢O.Klein,那也会在某种程度上有所帮助,但我仍然需要考虑第二种情况并消除像“购买白宫”这样的情况,因为当我使用slop时会被捕捉到。 - ameykpatil

0
其实我认为你的问题在于 PorterStemmer - "house" 被转换成了 "hous"。除非你真的认为需要它,否则我建议关闭 PorterStemmer。根据我的经验,它通常会带来更多的负面影响。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接