使用dismax搜索多字索引术语

时间:2021-02-17 19:56:38

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

我的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>

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.

在名义上,我已经索引了多个术语,如:“diego alberto milito”,“diego armando maradona”。我正在尝试在两个字段中进行搜索,使用dismax查询以不同方式对其进行搜索。

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

但尝试使用此查询: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.

solr一无所获。也许我不明白正确使用“符号”。

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

我也不理解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)"

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

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

并且在我的模式中,defaultOperator是OR为什么,如果没有设置mm = 0,我获得默认的mm值为100。

Thanks in advance!

提前致谢!

1 个解决方案

#1


0  

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.

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

#1


0  

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.

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