【问题标题】:Solr boolean queries combined with index-time boostsSolr 布尔查询与索引时间提升相结合
【发布时间】:2011-10-02 01:10:56
【问题描述】:

我有一个使用 Solr 1.4.1 进行相关性/推荐的网站。我在某些地方使用布尔样式的查询。我正在使用像 +(+type:aoh_company +aoh_dictionary_tids:623) 这样的查询 - 它提供了预期的结果,但结果的顺序似乎是任意的。

我试图通过设置索引时间提升来控制文档的排名,但它们似乎被这些查询忽略了。

一个例子

  • 查询网址为http://localhost:4930/solr/prod/select?rows=5&start=0&q.alt=(type%3Aaoh_company)+(aoh_dictionary_tids%3A623)&q=
  • 按以下顺序返回结果(括号中为索引时间提升值):
    1. 17132 (1.22)
    2. 17179 (1.02)
    3. 17131 (1.10)
    4. 17133 (1.10)
    5. 17184 (1.10)
  • 显然,仅基于提升,结果 #2 不应出现在 #3-5 之前。
  • 鉴于这是一个布尔查询,排名应该不会有太大差异。

调试输出

我尝试通过将debugQuery=true 附加到查询来调试上面的查询,所以它变成了http://localhost:4930/solr/prod/select?rows=5&start=0&q.alt=(type%3Aaoh_company)+(aoh_dictionary_tids%3A623)&q=&debugQuery=true

这很冗长,但这里是:

<lst name="debug">
  <null name="rawquerystring"/>
  <null name="querystring"/>
  <str name="parsedquery">+(+type:aoh_company +aoh_dictionary_tids:623)</str>
  <str name="parsedquery_toString">+(+type:aoh_company +aoh_dictionary_tids:623)</str>
  <lst name="explain">
    <str name="50hves/node/17132">
    1.7819747 = (MATCH) sum of:
      0.9014403 = (MATCH) weight(type:aoh_company in 1805), product of:
        0.37135038 = queryWeight(type:aoh_company), product of:
          2.4274657 = idf(docFreq=457, maxDocs=1909)
          0.15297863 = queryNorm
        2.4274657 = (MATCH) fieldWeight(type:aoh_company in 1805), product of:
          1.0 = tf(termFreq(type:aoh_company)=1)
          2.4274657 = idf(docFreq=457, maxDocs=1909)
          1.0 = fieldNorm(field=type, doc=1805)
      0.88053435 = (MATCH) weight(aoh_dictionary_tids:623 in 1805), product of:
        0.9284928 = queryWeight(aoh_dictionary_tids:623), product of:
          6.069428 = idf(docFreq=11, maxDocs=1909)
          0.15297863 = queryNorm
        0.9483481 = (MATCH) fieldWeight(aoh_dictionary_tids:623 in 1805), product of:
          1.0 = tf(termFreq(aoh_dictionary_tids:623)=1)
          6.069428 = idf(docFreq=11, maxDocs=1909)
          0.15625 = fieldNorm(field=aoh_dictionary_tids, doc=1805)
    </str>
    <str name="50hves/node/17179">
    1.7819747 = (MATCH) sum of:
      0.9014403 = (MATCH) weight(type:aoh_company in 1896), product of:
        0.37135038 = queryWeight(type:aoh_company), product of:
          2.4274657 = idf(docFreq=457, maxDocs=1909)
          0.15297863 = queryNorm
        2.4274657 = (MATCH) fieldWeight(type:aoh_company in 1896), product of:
          1.0 = tf(termFreq(type:aoh_company)=1)
          2.4274657 = idf(docFreq=457, maxDocs=1909)
          1.0 = fieldNorm(field=type, doc=1896)
      0.88053435 = (MATCH) weight(aoh_dictionary_tids:623 in 1896), product of:
        0.9284928 = queryWeight(aoh_dictionary_tids:623), product of:
          6.069428 = idf(docFreq=11, maxDocs=1909)
          0.15297863 = queryNorm
        0.9483481 = (MATCH) fieldWeight(aoh_dictionary_tids:623 in 1896), product of:
          1.0 = tf(termFreq(aoh_dictionary_tids:623)=1)
          6.069428 = idf(docFreq=11, maxDocs=1909)
          0.15625 = fieldNorm(field=aoh_dictionary_tids, doc=1896)
    </str>
    <str name="50hves/node/17131">
    1.7819747 = (MATCH) sum of:
      0.9014403 = (MATCH) weight(type:aoh_company in 1905), product of:
        0.37135038 = queryWeight(type:aoh_company), product of:
          2.4274657 = idf(docFreq=457, maxDocs=1909)
          0.15297863 = queryNorm
        2.4274657 = (MATCH) fieldWeight(type:aoh_company in 1905), product of:
          1.0 = tf(termFreq(type:aoh_company)=1)
          2.4274657 = idf(docFreq=457, maxDocs=1909)
          1.0 = fieldNorm(field=type, doc=1905)
      0.88053435 = (MATCH) weight(aoh_dictionary_tids:623 in 1905), product of:
        0.9284928 = queryWeight(aoh_dictionary_tids:623), product of:
          6.069428 = idf(docFreq=11, maxDocs=1909)
          0.15297863 = queryNorm
        0.9483481 = (MATCH) fieldWeight(aoh_dictionary_tids:623 in 1905), product of:
          1.0 = tf(termFreq(aoh_dictionary_tids:623)=1)
          6.069428 = idf(docFreq=11, maxDocs=1909)
          0.15625 = fieldNorm(field=aoh_dictionary_tids, doc=1905)
    </str>
    <str name="50hves/node/17133">
    1.7819747 = (MATCH) sum of:
      0.9014403 = (MATCH) weight(type:aoh_company in 1906), product of:
        0.37135038 = queryWeight(type:aoh_company), product of:
          2.4274657 = idf(docFreq=457, maxDocs=1909)
          0.15297863 = queryNorm
        2.4274657 = (MATCH) fieldWeight(type:aoh_company in 1906), product of:
          1.0 = tf(termFreq(type:aoh_company)=1)
          2.4274657 = idf(docFreq=457, maxDocs=1909)
          1.0 = fieldNorm(field=type, doc=1906)
      0.88053435 = (MATCH) weight(aoh_dictionary_tids:623 in 1906), product of:
        0.9284928 = queryWeight(aoh_dictionary_tids:623), product of:
          6.069428 = idf(docFreq=11, maxDocs=1909)
          0.15297863 = queryNorm
        0.9483481 = (MATCH) fieldWeight(aoh_dictionary_tids:623 in 1906), product of:
          1.0 = tf(termFreq(aoh_dictionary_tids:623)=1)
          6.069428 = idf(docFreq=11, maxDocs=1909)
          0.15625 = fieldNorm(field=aoh_dictionary_tids, doc=1906)
    </str>
    <str name="50hves/node/17184">
    1.6058679 = (MATCH) sum of:
      0.9014403 = (MATCH) weight(type:aoh_company in 1892), product of:
        0.37135038 = queryWeight(type:aoh_company), product of:
          2.4274657 = idf(docFreq=457, maxDocs=1909)
          0.15297863 = queryNorm
        2.4274657 = (MATCH) fieldWeight(type:aoh_company in 1892), product of:
          1.0 = tf(termFreq(type:aoh_company)=1)
          2.4274657 = idf(docFreq=457, maxDocs=1909)
          1.0 = fieldNorm(field=type, doc=1892)
      0.7044275 = (MATCH) weight(aoh_dictionary_tids:623 in 1892), product of:
        0.9284928 = queryWeight(aoh_dictionary_tids:623), product of:
          6.069428 = idf(docFreq=11, maxDocs=1909)
          0.15297863 = queryNorm
        0.7586785 = (MATCH) fieldWeight(aoh_dictionary_tids:623 in 1892), product of:
          1.0 = tf(termFreq(aoh_dictionary_tids:623)=1)
          6.069428 = idf(docFreq=11, maxDocs=1909)
          0.125 = fieldNorm(field=aoh_dictionary_tids, doc=1892)
    </str>
  </lst>
  <str name="QParser">DisMaxQParser</str>
  <str name="altquerystring">org.apache.lucene.search.BooleanQuery:+type:aoh_company +aoh_dictionary_tids:623</str>
  <null name="boostfuncs"/>
  <lst name="timing">
    <double name="time">7.0</double>
    <lst name="prepare">
      <double name="time">1.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.SpellCheckComponent">
    <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">6.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.SpellCheckComponent">
      <double name="time">0.0</double>
    </lst>
    <lst name="org.apache.solr.handler.component.DebugComponent">
      <double name="time">6.0</double>
    </lst>
  </lst>
</lst>

当我阅读它时,前四个结果的得分为1.7819747,第五个得分为1.6058679,我在其中的任何地方都看不到提升值,所以似乎它们不是影响因素排名方程。

那我做错了什么。我需要做些什么来让 Solr 考虑到这些提升吗?
有没有办法检查存储在 Solr 中的升压值?它在我发送给它的文档中看起来正确,但我找不到查看存储值的方法?

另外,这是我schema.xml的相关部分:

<types>
  <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
  <fieldType name="integer" class="solr.IntField" omitNorms="true"/>
</types>
<fields>
  <field name="type" type="string" indexed="true" stored="true"/>
  <field name="aoh_dictionary_tids"  type="integer" indexed="true" stored="true" multiValued="true" omitNorms="false"/>
</fields>

在下面的回答中,fyr 提到需要在现场启用规范才能应用提升值。所以我想稍微修改一下我的问题:

  • 是否足以在查询字段之一上启用规范以应用提升?
  • 我在字段上的omitNorms="false" 是否会覆盖字段类型上的omitNorms="true"

任何帮助将不胜感激。

【问题讨论】:

    标签: solr


    【解决方案1】:

    你不会在解释中看到提升。索引时的提升应用于某个文档中某个字段的规范。就像一个乘法器。

    如果您启用了 Norms,则在索引时使用您的 bosst 值。如果您使用 DefaultSimilarity 并且启用了 Norms,则 Norms 始终是相似度函数的一部分。

    修改后续问题:

    1. 启用规范以应用提升就足够了。因为规范为索引中的字段提供了索引中的数据权重结构。并且索引时间提升乘以规范值并保存到规范字段。

    2. 字段声明中的omitNorms 会覆盖类型定义 - 您也可以在说明结构中看到这一点。 aoh_dictionary 的值不等于 1。如果禁用规范,则默认应用 1。

    【讨论】:

    • 提升应用于整个文档。规范是针对特定领域的,对吧?
    • 索引时的提升确实是特定于文档的。但它仅适用于文档中启用了规范的字段。因此,如果您有两个字段 A(带规范)和 B(不带规范)并且您只查询 B,您将不会注意到任何差异。
    • 此外,如果您有可能在索引时设置字段提升,这在一定程度上取决于您的 solr 库。
    • 好的,感谢您迄今为止的意见。我发现我的架构或可能没有为其中一个字段启用规范,并为另一个字段禁用了它。我已经在问题中添加了架构详细信息,还有几个与此相关的额外问题:)
    • 我尝试在两个查询字段上启用规范,这似乎没有任何区别。尽管我找到了一种解决方法(将索引时间提升值存储在一个字段中并在排序参数中使用它),但这仍然没有解决。
    猜你喜欢
    • 2012-05-18
    • 2017-06-09
    • 1970-01-01
    • 2017-05-26
    • 2023-03-10
    • 1970-01-01
    • 2019-08-11
    • 2017-08-10
    • 2014-06-09
    相关资源
    最近更新 更多