Search code examples
solrsolrj

Solr Index : Parent / Child documents


I'm using Solr to index some contents but currently, theses contents are suposed to be parent / child related.

I'm having something like that:

<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>

But I would like to have something close to that:

<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>

I'm wondering if it's possible and how can I manage to define my schema.xml on that way?

I'm using Solr 3.6 and I can't change it.

I hope someone can give me a hand.

Regards, Dekx.


Solution

  • 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).