3

我正在使用 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,我无法更改它。

我希望有人能帮我一把。

问候,德克斯。

4

2 回答 2

6

SOLR 现在(从 4.5 开始?)支持/模拟父/子文档,请参见示例 SOLR 模式:

<!-- 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。但是很难找到任何文档。

于 2013-12-23T16:06:55.907 回答
1

Solr does not have subdocument structure. However, you can try using multivalued fields to map the content. You can also use delimited values.

Edit: The answer is for Solr v3.6 (as the question is also for v3.6)

as @iMysak mentioned Solr has started supporting nested documents in newer versions (from v4.8 as mentioned here).

于 2013-08-14T10:50:29.103 回答