Solr索引:父/子文档

时间:2013-08-14 10:30:06

标签: solr solrj

我正在使用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。

2 个答案:

答案 0 :(得分: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。但是很难找到任何文档。

答案 1 :(得分:1)

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

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

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

相关问题