使用 dismax 搜索多字索引术语

发布于 2025-01-05 07:41:08 字数 3617 浏览 2 评论 0原文

我的 solr 架构如下(仅重要部分):

<fieldType name="bagofwords_expertfinding" class="solr.TextField"    positionIncrementGap="100">
  <analyzer type="index">
    <!-- remove letters repeated more than two times -->
    <charFilter class="solr.HTMLStripCharFilterFactory"/>
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory"
            ignoreCase="true"
            words="stopwords_en.txt"
            enablePositionIncrements="true"
            />
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.EnglishPossessiveFilterFactory"/>
    <filter class="solr.PatternReplaceFilterFactory" pattern="^[0-9-/_,\.]+$" replacement="" replace="all"/>
    <filter class="solr.PatternReplaceFilterFactory" pattern="^.*(([aA-zZ])\\2)\\2+.*$" replacement=""/>
    <filter class="solr.PorterStemFilterFactory"/>
    <filter class="solr.LengthFilterFactory" min="3" max="100"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory"
            ignoreCase="true"
            words="stopwords_en.txt"
            enablePositionIncrements="true"
            />
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.EnglishPossessiveFilterFactory"/>
    <filter class="solr.PatternReplaceFilterFactory" pattern="^[0-9-/_,\.]+$" replacement="" replace="all"/> 
    <filter class="solr.PorterStemFilterFactory"/>
    <filter class="solr.LengthFilterFactory" min="3" max="100"/>
  </analyzer>
</fieldType>
<fieldType name="namedentities_expertfinding" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <!-- remove letters repeated more than two times -->
    <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="\s," replacement=","/>
    <charFilter class="solr.PatternReplaceCharFilterFactory" pattern=",\s" replacement=","/>
    <tokenizer class="solr.PatternTokenizerFactory" pattern="," />
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.StopFilterFactory"
            ignoreCase="true"
            words="stopwords_en.txt"
            enablePositionIncrements="true"
            />
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.EnglishPossessiveFilterFactory"/>
    <filter class="solr.PatternReplaceFilterFactory" pattern="^[0-9-/_,\.]+$" replacement="" replace="all"/> 
    <filter class="solr.LengthFilterFactory" min="3" max="100"/>
  </analyzer>
</fieldType>

在命名实体中,我索引了多词术语,例如:“diego alberto milito”、“diego armando maradona”。我正在尝试使用 dismax 查询在这两个字段中进行搜索,以不同的方式提升它们。

但尝试使用这个查询: localhost:8080/solr/select/?q="diego armando maradona"&defType=dismax&qf=namedentities^100 bagofwords^1&fl=*,score&debugQuery=true&mm=0

solr 找不到任何内容。也许我不明白 " 符号的正确用法。

我也不明白 solr wiki 中的这一点:

“在 Solr 1.4 及之前的版本中,如果你想要 q.op=OR 的等价物,你基本上应该设置 mm=0 ,如果您想要 q.op=AND 的等价物,则 mm=100%。在 3.x 和 trunk 中,mm 的默认值由 q.op 参数决定(q.op=AND => mm=100%;q.op=OR => mm=0%)。请记住,默认运算符受 schema.xml 条目的影响。在旧版本的 Solr 中,默认值为 100%(所有子句必须匹配)”,

并且考虑到在我的架构中,defaultOperator 是 OR,为什么在不设置 mm=0 的情况下,我获得默认 mm 值为 100。

提前致谢!

My solr schema is the following ( only important parts):

<fieldType name="bagofwords_expertfinding" class="solr.TextField"    positionIncrementGap="100">
  <analyzer type="index">
    <!-- remove letters repeated more than two times -->
    <charFilter class="solr.HTMLStripCharFilterFactory"/>
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory"
            ignoreCase="true"
            words="stopwords_en.txt"
            enablePositionIncrements="true"
            />
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.EnglishPossessiveFilterFactory"/>
    <filter class="solr.PatternReplaceFilterFactory" pattern="^[0-9-/_,\.]+$" replacement="" replace="all"/>
    <filter class="solr.PatternReplaceFilterFactory" pattern="^.*(([aA-zZ])\\2)\\2+.*$" replacement=""/>
    <filter class="solr.PorterStemFilterFactory"/>
    <filter class="solr.LengthFilterFactory" min="3" max="100"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory"
            ignoreCase="true"
            words="stopwords_en.txt"
            enablePositionIncrements="true"
            />
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.EnglishPossessiveFilterFactory"/>
    <filter class="solr.PatternReplaceFilterFactory" pattern="^[0-9-/_,\.]+$" replacement="" replace="all"/> 
    <filter class="solr.PorterStemFilterFactory"/>
    <filter class="solr.LengthFilterFactory" min="3" max="100"/>
  </analyzer>
</fieldType>
<fieldType name="namedentities_expertfinding" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <!-- remove letters repeated more than two times -->
    <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="\s," replacement=","/>
    <charFilter class="solr.PatternReplaceCharFilterFactory" pattern=",\s" replacement=","/>
    <tokenizer class="solr.PatternTokenizerFactory" pattern="," />
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.StopFilterFactory"
            ignoreCase="true"
            words="stopwords_en.txt"
            enablePositionIncrements="true"
            />
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.EnglishPossessiveFilterFactory"/>
    <filter class="solr.PatternReplaceFilterFactory" pattern="^[0-9-/_,\.]+$" replacement="" replace="all"/> 
    <filter class="solr.LengthFilterFactory" min="3" max="100"/>
  </analyzer>
</fieldType>

In namedentities i have indexed multiword terms like: "diego alberto milito","diego armando maradona". I'm trying to search in both fields boosting them differently with a dismax query.

But trying with this query:
localhost:8080/solr/select/?q="diego armando maradona"&defType=dismax&qf=namedentities^100 bagofwords^1&fl=*,score&debugQuery=true&mm=0

solr doesn't find nothing. Maybe i don't understand the correct use of " symbol.

I don't understand also given this from solr wiki:

"In Solr 1.4 and prior, you should basically set mm=0 if you want the equivilent of q.op=OR, and mm=100% if you want the equivilent of q.op=AND. In 3.x and trunk the default value of mm is dictated by the q.op param (q.op=AND => mm=100%; q.op=OR => mm=0%). Keep in mind the default operator is effected by your schema.xml entry. In older versions of Solr the default value is 100% (all clauses must match)"

and given that in my schema the defaultOperator is OR why, without setting mm=0, i obtain a default mm value of 100.

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美煞众生 2025-01-12 07:41:08

在上面的查询字符串周围加上引号会强制进行短语查询。这意味着仅考虑完全匹配。删除它们,用括号替换,并尝试使用 pf 和 pf2 和 pf3 参数来增强更长的匹配短语。

Having the quotes around the query string above is forcing a phrase query. This means only exact matches are considered. Remove them, replacing with parens, and experiment with the pf and pf2 and pf3 parameters to boost longer matching phrases.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文