0

当我在我的 solr 3.6.2 debian 服务器上使用 dismax 和 edismax 执行两次相同的查询时,我得到了 dismax 4 结果,如预期的那样,但 edismax 0 结果。

下面你会发现 3 个在同一索引上运行的示例。该索引包含一条记录“label:M025 Some-Example Record”

  1. Edismax 与:q=M025 没有结果。
  2. Dismax 与:q=M025 找到 4 个项目。
  3. Edismax 与:q=找到 1 个项目的示例。

为什么 EDISMAX 没有找到“M025”而是“Example”?

Solr 架构

<fieldType name="text" class="solr.TextField" positionIncrementGap="100">
    <analyzer type="index">
        <charFilter class="solr.MappingCharFilterFactory" mapping="txt/mapping-ISOLatin1Accent.txt" />
        <tokenizer class="solr.WhitespaceTokenizerFactory" />
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="txt/stopwords.txt" enablePositionIncrements="true" />
        <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="0" preserveOriginal="1" />
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.SnowballPorterFilterFactory" language="German2" protected="txt/protwords.txt" />
        <filter class="solr.SnowballPorterFilterFactory" language="Italian" protected="txt/protwords.txt" />
        <filter class="solr.SnowballPorterFilterFactory" language="French" protected="txt/protwords.txt" />
        <filter class="solr.RemoveDuplicatesTokenFilterFactory" />
        <filter class="solr.NGramFilterFactory" minGramSize="2" maxGramSize="25" />
    </analyzer>
    <analyzer type="query">
        <charFilter class="solr.MappingCharFilterFactory" mapping="txt/mapping-ISOLatin1Accent.txt" />
        <tokenizer class="solr.WhitespaceTokenizerFactory" />
        <filter class="solr.SynonymFilterFactory" synonyms="txt/synonyms.txt" ignoreCase="true" expand="true" />
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="txt/stopwords.txt" enablePositionIncrements="true" />
        <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="0" preserveOriginal="1" />
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.SnowballPorterFilterFactory" language="German2" protected="txt/protwords.txt" />
        <filter class="solr.SnowballPorterFilterFactory" language="Italian" protected="txt/protwords.txt" />
        <filter class="solr.SnowballPorterFilterFactory" language="French" protected="txt/protwords.txt" />
    </analyzer>
</fieldType>

<field name="label" type="text" indexed="true" stored="true" termVectors="true" omitNorms="true" required="true" />

示例 EDISMAX

http://127.0.0.1:8080/solr/select?defType=edismax&qf=label&fl=label&q=M025&fq=model:Model_DbTable_Site&debugQuery=true   
<?xml version="1.0" encoding="UTF-8"?>
<response>
   <lst name="responseHeader">
      <int name="status">0</int>
      <int name="QTime">3</int>
      <lst name="params">
         <str name="fl">label</str>
         <str name="echoParams">all</str>
         <str name="qf">label</str>
         <str name="hl.fl">teaser</str>
         <str name="wt">xml</str>
         <str name="rows">25</str>
         <str name="defType">edismax</str>
         <str name="fl">label</str>
         <str name="debugQuery">true</str>
         <str name="q">M025</str>
         <str name="qf">label</str>
         <str name="fq">model:Model_DbTable_Site</str>
         <str name="defType">edismax</str>
      </lst>
   </lst>
   <result name="response" numFound="0" start="0" />
   <lst name="debug">
      <str name="rawquerystring">M025</str>
      <str name="querystring">M025</str>
      <str name="parsedquery">+DisjunctionMaxQuery((((label:m025 label:m label:025)~3)))</str>
      <str name="parsedquery_toString">+(((label:m025 label:m label:025)~3))</str>
      <lst name="explain" />
      <str name="QParser">ExtendedDismaxQParser</str>
      <null name="altquerystring" />
      <null name="boostfuncs" />
      <arr name="filter_queries">
         <str>model:Model_DbTable_Site</str>
      </arr>
      <arr name="parsed_filter_queries">
         <str>model:Model_DbTable_Site</str>
      </arr>
      <lst name="timing">
         <double name="time">2.0</double>
         <lst name="prepare">
            <double name="time">1.0</double>
            <lst name="org.apache.solr.handler.component.QueryComponent">
               <double name="time">1.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.FacetComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.MoreLikeThisComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.HighlightComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.StatsComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.DebugComponent">
               <double name="time">0.0</double>
            </lst>
         </lst>
         <lst name="process">
            <double name="time">1.0</double>
            <lst name="org.apache.solr.handler.component.QueryComponent">
               <double name="time">1.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.FacetComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.MoreLikeThisComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.HighlightComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.StatsComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.DebugComponent">
               <double name="time">0.0</double>
            </lst>
         </lst>
      </lst>
   </lst>
</response>

示例 DISMAX

http://127.0.0.1:8080/solr/select?defType=dismax&qf=label&fl=label&q=M025&fq=model:Model_DbTable_Site&debugQuery=true   
<?xml version="1.0" encoding="UTF-8"?>
<response>
   <lst name="responseHeader">
      <int name="status">0</int>
      <int name="QTime">21</int>
      <lst name="params">
         <str name="fl">label</str>
         <str name="echoParams">all</str>
         <str name="qf">label</str>
         <str name="hl.fl">teaser</str>
         <str name="wt">xml</str>
         <str name="rows">25</str>
         <str name="defType">dismax</str>
         <str name="fl">label</str>
         <str name="debugQuery">true</str>
         <str name="q">M025</str>
         <str name="qf">label</str>
         <str name="fq">model:Model_DbTable_Site</str>
         <str name="defType">dismax</str>
      </lst>
   </lst>
   <result name="response" numFound="4" start="0">
      <doc>
         <str name="label">M025 Some-Example Record</str>
      </doc>
      <doc>
         <str name="label">S025 ******************</</str>
      </doc>
      <doc>
         <str name="label">ES025 ******************</str>
      </doc>
      <doc>
         <str name="label">WK025 ******************</</str>
      </doc>
   </result>
   <lst name="debug">
      <str name="rawquerystring">M025</str>
      <str name="querystring">M025</str>
      <str name="parsedquery">+DisjunctionMaxQuery(((label:m025 label:m label:025))) ()</str>
      <str name="parsedquery_toString">+((label:m025 label:m label:025)) ()</str>
      <lst name="explain">
         <str name="Model_DbTable_Site_1">4.7416363 = (MATCH) sum of:
  4.7416363 = (MATCH) product of:
    7.112454 = (MATCH) sum of:
      3.277886 = (MATCH) weight(label:m025 in 7440), product of:
        0.4947139 = queryWeight(label:m025), product of:
          6.625821 = idf(docFreq=27, maxDocs=7770)
          0.07466454 = queryNorm
        6.625821 = (MATCH) fieldWeight(label:m025 in 7440), product of:
          1.0 = tf(termFreq(label:m025)=1)
          6.625821 = idf(docFreq=27, maxDocs=7770)
          1.0 = fieldNorm(field=label, doc=7440)
      3.834568 = (MATCH) weight(label:025 in 7440), product of:
        0.44994345 = queryWeight(label:025), product of:
          6.0262 = idf(docFreq=50, maxDocs=7770)
          0.07466454 = queryNorm
        8.522333 = (MATCH) fieldWeight(label:025 in 7440), product of:
          1.4142135 = tf(termFreq(label:025)=2)
          6.0262 = idf(docFreq=50, maxDocs=7770)
          1.0 = fieldNorm(field=label, doc=7440)
    0.6666667 = coord(2/3)</str>
         <str name="Model_DbTable_Site_239">1.2781894 = (MATCH) sum of:
  1.2781894 = (MATCH) product of:
    3.834568 = (MATCH) sum of:
      3.834568 = (MATCH) weight(label:025 in 428), product of:
        0.44994345 = queryWeight(label:025), product of:
          6.0262 = idf(docFreq=50, maxDocs=7770)
          0.07466454 = queryNorm
        8.522333 = (MATCH) fieldWeight(label:025 in 428), product of:
          1.4142135 = tf(termFreq(label:025)=2)
          6.0262 = idf(docFreq=50, maxDocs=7770)
          1.0 = fieldNorm(field=label, doc=428)
    0.33333334 = coord(1/3)</str>
         <str name="Model_DbTable_Site_61">1.2781894 = (MATCH) sum of:
  1.2781894 = (MATCH) product of:
    3.834568 = (MATCH) sum of:
      3.834568 = (MATCH) weight(label:025 in 83), product of:
        0.44994345 = queryWeight(label:025), product of:
          6.0262 = idf(docFreq=50, maxDocs=7770)
          0.07466454 = queryNorm
        8.522333 = (MATCH) fieldWeight(label:025 in 83), product of:
          1.4142135 = tf(termFreq(label:025)=2)
          6.0262 = idf(docFreq=50, maxDocs=7770)
          1.0 = fieldNorm(field=label, doc=83)
    0.33333334 = coord(1/3)</str>
         <str name="Model_DbTable_Site_51">1.2781894 = (MATCH) sum of:
  1.2781894 = (MATCH) product of:
    3.834568 = (MATCH) sum of:
      3.834568 = (MATCH) weight(label:025 in 43), product of:
        0.44994345 = queryWeight(label:025), product of:
          6.0262 = idf(docFreq=50, maxDocs=7770)
          0.07466454 = queryNorm
        8.522333 = (MATCH) fieldWeight(label:025 in 43), product of:
          1.4142135 = tf(termFreq(label:025)=2)
          6.0262 = idf(docFreq=50, maxDocs=7770)
          1.0 = fieldNorm(field=label, doc=43)
    0.33333334 = coord(1/3)</str>
      </lst>
      <str name="QParser">DisMaxQParser</str>
      <null name="altquerystring" />
      <null name="boostfuncs" />
      <arr name="filter_queries">
         <str>model:Model_DbTable_Site</str>
      </arr>
      <arr name="parsed_filter_queries">
         <str>model:Model_DbTable_Site</str>
      </arr>
      <lst name="timing">
         <double name="time">21.0</double>
         <lst name="prepare">
            <double name="time">1.0</double>
            <lst name="org.apache.solr.handler.component.QueryComponent">
               <double name="time">1.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.FacetComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.MoreLikeThisComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.HighlightComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.StatsComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.DebugComponent">
               <double name="time">0.0</double>
            </lst>
         </lst>
         <lst name="process">
            <double name="time">20.0</double>
            <lst name="org.apache.solr.handler.component.QueryComponent">
               <double name="time">18.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.FacetComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.MoreLikeThisComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.HighlightComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.StatsComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.DebugComponent">
               <double name="time">2.0</double>
            </lst>
         </lst>
      </lst>
   </lst>
</response>

带有名称的 EDISMAX 示例

http://127.0.0.1:8080/solr/select?defType=edismax&qf=label&fl=label&q=Example&fq=model:Model_DbTable_Site&debugQuery=true
<?xml version="1.0" encoding="UTF-8"?>
<response>
   <lst name="responseHeader">
      <int name="status">0</int>
      <int name="QTime">1</int>
      <lst name="params">
         <str name="fl">label</str>
         <str name="echoParams">all</str>
         <str name="qf">label</str>
         <str name="hl.fl">teaser</str>
         <str name="wt">xml</str>
         <str name="rows">25</str>
         <str name="defType">edismax</str>
         <str name="fl">label</str>
         <str name="debugQuery">true</str>
         <str name="q">Example</str>
         <str name="qf">label</str>
         <str name="fq">model:Model_DbTable_Site</str>
         <str name="defType">edismax</str>
      </lst>
   </lst>
   <result name="response" numFound="1" start="0">
      <doc>
         <str name="label">M025 Some-Example Record</str>
      </doc>
   </result>
   <lst name="debug">
      <str name="rawquerystring">Example</str>
      <str name="querystring">Example</str>
      <str name="parsedquery">+DisjunctionMaxQuery((label:example))</str>
      <str name="parsedquery_toString">+(label:example)</str>
      <lst name="explain">
         <str name="Model_DbTable_Site_1">9.264878 = (MATCH) fieldWeight(label:example in 7440), product of:
  1.0 = tf(termFreq(label:example)=1)
  9.264878 = idf(docFreq=1, maxDocs=7770)
  1.0 = fieldNorm(field=label, doc=7440)</str>
      </lst>
      <str name="QParser">ExtendedDismaxQParser</str>
      <null name="altquerystring" />
      <null name="boostfuncs" />
      <arr name="filter_queries">
         <str>model:Model_DbTable_Site</str>
      </arr>
      <arr name="parsed_filter_queries">
         <str>model:Model_DbTable_Site</str>
      </arr>
      <lst name="timing">
         <double name="time">1.0</double>
         <lst name="prepare">
            <double name="time">0.0</double>
            <lst name="org.apache.solr.handler.component.QueryComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.FacetComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.MoreLikeThisComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.HighlightComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.StatsComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.DebugComponent">
               <double name="time">0.0</double>
            </lst>
         </lst>
         <lst name="process">
            <double name="time">1.0</double>
            <lst name="org.apache.solr.handler.component.QueryComponent">
               <double name="time">1.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.FacetComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.MoreLikeThisComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.HighlightComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.StatsComponent">
               <double name="time">0.0</double>
            </lst>
            <lst name="org.apache.solr.handler.component.DebugComponent">
               <double name="time">0.0</double>
            </lst>
         </lst>
      </lst>
   </lst>
</response>
4

1 回答 1

0

在写完这篇文章后,我找到了解决方案。

我不太清楚为什么 DISMAX 会发现任何东西,但问题是名称。我的架构中的原始内容是:

<filter class="solr.NGramFilterFactory" minGramSize="2" maxGramSize="25" />

在解析的查询中是

+DisjunctionMaxQuery((((label:m025 label:m label:025)~3)))

所以字母和数字将被拆分,因此一个 ngram 是“m”,第二个是“025”,因为“m”长度小于 2,所以它被忽略了。

更改为后

<filter class="solr.NGramFilterFactory" minGramSize="1" maxGramSize="25" />

我得到了我所期望的结果。

于 2014-07-24T08:14:19.120 回答