Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sample nested documents to demonstrate block join indexing and searching in Solr 4.5
id,_version_,BRAND_s,_root_,type_s,COLOR_s,SIZE_s
12,,,10,,Blue,XL
11,,,10,,Red,XL
10,1445176108735528960,Nike,10,parent,,
22,,,20,,Blue,XL
21,,,20,,Red,M
20,1445176108738674688,Nike,20,parent,,
32,,,30,,Blue,M
31,,,30,,Red,XL
30,1445176108740771840,Puma,30,parent,,
<field name="_root_" type="int" indexed="true" stored="true" multiValued="false" required="false"/>
<cache name="perSegFilter" class="solr.search.LRUCache"
size="10" initialSize="0" autowarmCount="10" />
<update>
<delete><query>*:*</query></delete>
<add>
<doc>
<field name="id">10</field>
<field name="type_s">parent</field>
<field name="BRAND_s">Nike</field>
<doc>
<field name="id">11</field>
<field name="COLOR_s">Red</field>
<field name="SIZE_s">XL</field>
</doc>
<doc>
<field name="id">12</field>
<field name="COLOR_s">Blue</field>
<field name="SIZE_s">XL</field>
</doc>
</doc>
<doc>
<field name="id">20</field>
<field name="type_s">parent</field>
<field name="BRAND_s">Nike</field>
<doc>
<field name="id">21</field>
<field name="COLOR_s">Red</field>
<field name="SIZE_s">M</field>
</doc>
<doc>
<field name="id">22</field>
<field name="COLOR_s">Blue</field>
<field name="SIZE_s">XL</field>
</doc>
</doc>
<doc>
<field name="id">30</field>
<field name="type_s">parent</field>
<field name="BRAND_s">Puma</field>
<doc>
<field name="id">31</field>
<field name="COLOR_s">Red</field>
<field name="SIZE_s">XL</field>
</doc>
<doc>
<field name="id">32</field>
<field name="COLOR_s">Blue</field>
<field name="SIZE_s">M</field>
</doc>
</doc>
</add>
<commit/>
</update>
@rambabu
Copy link

rambabu commented May 22, 2014

Can you please provide the sample example like how to import data from DB for nested docs.

my data-config.xml

                <entity name="address" query="">
                        <field column="addr1" name="addr1" />
                        <field column="addr2" name="addr2" />
                        <field column="pincode" name="pincode" />

                </entity>

My schema.xml


JSON response is:

"docs": [
{
"personid": "8",
"name": "ram",
"age": "25",
"version": 1468822660646436900
}
}

but I AM EXPECTING the following response:

"docs": [
{
"personid": "8",
"name": "ram",
"age": "25",
"address":{
"addr1":"test",
"addr2":"test",
"pincode":"test",
}
"version": 1468822660646436900
}
}

Can you please suggest how to get above response?
Am i doing any thing wrong in schema.xml file.

@rambabu
Copy link

rambabu commented May 22, 2014

Can you please provide the sample example like how to import data from DB for nested docs.

my data-config.xml

                <entity name="address" query="">
                        <field column="addr1" name="addr1" />
                        <field column="addr2" name="addr2" />
                        <field column="pincode" name="pincode" />

                </entity>

My schema.xml


JSON response is:

"docs": [
{
"personid": "8",
"name": "ram",
"age": "25",
"version": 1468822660646436900
}
}

but I AM EXPECTING the following response:

"docs": [
{
"personid": "8",
"name": "ram",
"age": "25",
"address":{
"addr1":"test",
"addr2":"test",
"pincode":"test",
}
"version": 1468822660646436900
}
}

Can you please suggest how to get above response?
Am i doing any thing wrong in schema.xml file.

@mkhludnev
Copy link
Author

mkhludnev commented Jun 15, 2015

rambabu,
I can't catch the problem. note DIH was recently extended to support block nesting https://issues.apache.org/jira/browse/SOLR-5147 child=true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment