sariDon
sariDon

Reputation: 7981

Schema for adding and indexing nested documents in SOLR

I am new to SOLR and trying to use SOLR 9.0.0 to index nested documents like:

{
"atype": "Regular", "asec":"domestic",  "aword": "Jack", "adesc": "seller member",
"product": [{"type":"handkerchiefs", "colors": ["red", "green], "sizes":["43"]}]
}

Trial #1:

ERROR: [doc=951592f2-141e-473c-aab0-4203ee24a305/product#] unknown field 'type'

schema.xml:

...
<fieldType name="_nest_path_" class="solr.NestPathField"/>
...
<field name="_root_" type="string" indexed="true" stored="false" docValues="false"/>
...
<field name="_nest_path_" type="_nest_path_" />
<field name="_nest_parent_" type="string" indexed="true" stored="true" />
...

Trial #2:

ERROR: [doc=null] unknown field 'type'

schema.xml

...
<fieldType name="_nest_path_" class="solr.NestPathField"/>
...
<field name="_root_" type="string" indexed="true" stored="false" docValues="false"/>
...
<field name="product" type="_nest_path_">
<field name="id" type="string" multiValued="false" required="true" stored="true"/>
<field name="type" type="string" indexed="true" stored="true"/>
<field name="colors" type="strings" multiValued="true" indexed="true" stored="true"/>
<field name="sizes" type="strings" multiValued="true" indexed="true" stored="true"/>
</field>
<field name="product_parent" type="string" indexed="true" stored="true" />
...

Trial #3:

ERROR: [doc=null] missing required field: adesc

schema.xml

...
<fieldType name="_nest_path_" class="solr.NestPathField"/>
...
<field name="_root_" type="string" indexed="true" stored="false" docValues="false"/>
...
<field name="adesc" type="text" multiValued="false" indexed="true" required="true" stored="true"/>
...
<field name="_nest_path_" type="_nest_path_" />
<field name="_nest_parent_" type="string" indexed="true" stored="true" />
    
<field name="type" type="string" indexed="true" stored="true"/>
<field name="colors" type="string" multiValued="true" indexed="true" stored="true"/>
<field name="sizes" type="string" multiValued="true" indexed="true" stored="true"/>
...

Can anyone please help?

(PS: The schema works fine when I remove the nesting section fields and data)

Upvotes: 0

Views: 17

Answers (0)

Related Questions