Solr 搜索顶级和嵌套记录

Solr search top level and nested records

我正在寻找一个 Solr 搜索系统,该系统 returns 不仅可以搜索顶级记录,还可以搜索子项(返回其父记录)。

我是 运行 Solr 8.8.1,模式示例如下

<field name="solr_type" type="string" indexed="true" stored="true" />
<field name="path" type="string" indexed="true" stored="true" />
<field name="_root_" type="string" indexed="true" stored="false" docValues="false" />

<fieldType name="_nest_path_" class="solr.NestPathField" />
<field name="nest_path" type="_nest_path_" />

还有这样的示例 parent/child 记录,请注意有些记录没有子记录

{
  "dc_identifier_s": "41ef95d3cbc8473888d1734412bf82f0-4",
  "dc_title_s": "CRB_Hydrologic",
  "solr_type":"parent"
    "_childDocuments_": [
    {

      "dc_identifier_s": "41ef95d3cbc8473888d1734412bf82f0_0-4",
      "dc_title_s": "CR HUC1"
      "solr_type":"child"
    }]
}

我一直按照此处的说明进行操作 (https://solr.apache.org/guide/8_0/searching-nested-documents.html),但由于 'nest_path' 未填充,我选择使用我设置的自定义字段 'solr_type' 'parent' 或 'child'

任何关于如何搜索所有记录但将结果限制在顶级和子记录的父级的指导将不胜感激。

谢谢

您想要根文档,但要根据子文档中的匹配项查找(搜索),也许还需要根文档中的匹配项?这是“父”查询解析器的直接应用 described in the guide;像这样:

&q={!parent which="*:* -_nest_path_:*" v=$q.nest}
&q.nest=real user query goes here

您没有描述您的查询的其他特征(上面 q.nest 中的内容;我编写的任意命名参数)——也许是 edismax 或谁知道是什么。如果您需要限制对某些文档的匹配(比如简单的字段=值或空间),您需要在其中编写一个更有趣的查询;您不能使用过滤器查询 (fq),因为过滤器查询会过滤 q 匹配的文档,这只是根文档。所以 q.nest 可能类似于 +{!geofilt} +field:value +{!edismax v=$q.user} 我建议使用比 8.0 更新的 Solr 版本(你指的是 8.0 文档),但我相信 8.0 仍然可以工作。我特别不建议嵌套文档的早期版本。