Solr索引:父/子文档

问题描述 投票:3回答:2

我正在使用Solr来索引某些内容但是目前,这些内容被认为是与父/子相关的。

我有类似的东西:

<doc>
  <id>*an Id*</id>
  <path>*a path*</path>
  <title>*a title*</title>
  <type>**Page**</type>
</doc>
<doc>
  <id>*an other Id*</id>
  <path>*a other path*</path>
  <title>*a other title*</title>
  <type>**Component**</type>
</doc>

但我想有一些接近的东西:

<doc>
  <id>*an Id*</id>
  <path>*a path*</path>
  <title>*a title*</title>
  <type>**Page**</type>
  <child>
    <id>*an Id*</id>
    <path>*a path*</path>
    <title>*a title*</title>
    <type>**Component**</type>
  </child>
</doc>

我想知道它是否可能,我怎样才能设法定义我的schema.xml

我正在使用Solr 3.6,我无法改变它。

我希望有人可以帮我一臂之力。

此致,Dekx。

solr solrj
2个回答
1
投票

Solr没有子文档结构。但是,您可以尝试使用多值字段来映射内容。您还可以使用分隔值。

编辑:答案是Solr v3.6(因为问题也适用于v3.6)

正如@iMysak所说,Solr已经开始支持更新版本的嵌套文档(从v4.8提到here)。


6
投票

SOLR现在(自4.5?)支持/模拟父/子文档,请参阅示例SOLR-schema:

<!-- points to the root document of a block of nested documents. Required for nested
document support, may be removed otherwise -->
<field name="_root_" type="string" indexed="true" stored="false"/> 

甚至SOLR-J也支持将childDocuments添加到SolrInputDocument。但很难找到任何文件。

© www.soinside.com 2019 - 2024. All rights reserved.