Solr我得到的结果是dismax但不是edismax

时间:2014-07-24 07:57:24

标签: solr edismax dismax

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

以下您将找到在同一索引上运行的3个示例。 该索引包括一个记录"标签:M025 Some-Example Record"

  1. Edismax:q = M025没有结果。
  2. Dismax with:q = M025,找到4项。
  3. Edismax with:q =找到1项的例子。
  4. 为什么EDISMAX找不到" M025"但是"示例"?

    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>
    

1 个答案:

答案 0 :(得分: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" />

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