【问题标题】:Solr Block Join Children Query Parser with query that matches non Parent DocsSolr Block Join Children Query Parser with query that match non Parent Docs
【发布时间】:2016-10-31 17:04:19
【问题描述】:

我一直在使用带有嵌套文档的 Solr 6.2.1,并尝试使用 Block Join Children Query Parser 检索特定类型父级的所有子文档,但是我收到以下错误:

父查询产生的文档与父过滤器不匹配

我的文档类似于:

<add>
  <doc>
  <field name="id">1</field>
  <field name="type">MYDOCTYPE</field>
  <field name="isParent">true</field>
    <doc>
      <field name="id">1_1</field>  
      <field name="comments">some comments</field>
    </doc>
    <doc>
      <field name="id">1_2</field>  
      <field name="comments">some more comments</field>
    </doc>
  </doc>
  <doc>
  <field name="id">2</field>
  <field name="type">MYDOCTYPE</field>
  <field name="isParent">true</field>
    <doc>
      <field name="id">2_1</field>  
      <field name="comments">some comments</field>
    </doc>
    <doc>
      <field name="id">2_2</field>  
      <field name="comments">some more comments</field>
    </doc>
  </doc>
  <doc>
  <field name="id">3</field>
  <field name="type">MYDOCTYPE</field>
  </doc>
</add>

我正在尝试通过以下方式查询它们:q={!child of="isParent:true"}type:MYDOCTYPE

我想问题是文档 3 的类型为 MYDOCTYPE 但不是父文档,因为它没有子文档,所以它是有道理的。

有没有在不将字段isParent 添加到文档 3 的情况下检索所有子文档?

【问题讨论】:

    标签: solr


    【解决方案1】:

    我找到了一个解决方法,那就是进行查询:

    {!child of="isParent:true"}type:"EDH/MAG"+isParent:true

    这样查询的第二部分只匹配 doc 1 和 2,不会抛出异常。

    【讨论】:

      【解决方案2】:

      这是个老问题,但也许我的回答对某人有帮助。

      id=3的doc被当做child处理是对的,由此产生错误。

      也许我们可以假设父文档是具有 isParent:true 或不为空的 type 字段且具有 id 的文档,那么查询可能看起来像这样:

      q={!child of="isParent:true OR (id:* AND type:*)"}type:MYDOCTYPE
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-08-21
        • 2021-09-28
        相关资源
        最近更新 更多