This is my schema file :
This is my schema file :
`<?xml version="1.0" encoding="UTF-8" ?>
<schema name="default-config" version="1.6">
<types>
<fieldType name="string" class="solr.StrField" />
<fieldType name="pint" class="solr.IntPointField" docValues="true" />
<fieldType name="date" class="solr.TrieDateField" />
<fieldType name="text_custom" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="_version_" class="solr.LongPointField" docValues="true" />
<fieldType name="_nest_path_" class="solr.NestPathField" />
</types>
<fields>
<field name="id" type="string" indexed="true" stored="true" required="true" />
<field name="user" type="string" indexed="true" stored="true" />
<field name="post" type="text_custom" indexed="true" stored="true" />
<field name="likes_count" type="pint" indexed="true" stored="true" />
<field name="_nest_path_" type="_nest_path_" />
<field name="comments" type="_nest_path_" indexed="true" stored="true" multiValued="true" />
<field name="comments.id" type="string" indexed="true" stored="true" multiValued="true" />
<field name="comments.user" type="string" indexed="true" stored="true" />
<field name="comments.comment" type="text_custom" indexed="true" stored="true" />
<field name="comments.timestamp" type="date" indexed="true" stored="true" />
<field name="title" type="text_custom" indexed="true" stored="true" />
<field name="content" type="text_custom" indexed="true" stored="true" />
<field name="_version_" type="_version_" indexed="true" stored="true" />
<field name="_root_" type="string" indexed="true" stored="false" docValues="false" />
<dynamicField name="*_str" type="string" indexed="true" stored="true" />
</fields>
<uniqueKey>id</uniqueKey>
</schema>
And im trying to index this data
the output is like this
"response":{"numFound":2,"start":0,"maxScore":1.0,"numFoundExact":true,"docs":\[
{
"id":"3554",
"user":"user50",
"_version_":1774028322530918400},
{
"id":"4",
"user":"user4",
"post":"This is a sample post by 4.",
"likes_count":60,
"title":"Sample Title 4",
"content":"This is the content of document 4.",
"_version_":1774028322530918400}\]
}}
but my expected output is
"response":{"numFound":2,"start":0,"maxScore":1.0,"numFoundExact":true,"docs":\[
{
"id":"4",
"user":"user4",
"post":"This is a sample post by 4.",
"likes_count":60,
"title":"Sample Title 4",
{
"id":"3554",
"user":"user50",
"_version_":1774028322530918400
},
"content":"This is the content of document 4.",
"_version_":1774028322530918400}\]
}}
where I'm doing mistake ???
I want the data to in nested format in solrcloud like what im indexing. I want my datas to be indexed in the nested format
Indexing nested documents requires an indexed field named _root_
:
<field name="_root_" type="string" indexed="true" stored="false" docValues="false" />
Solr automatically populates this field in all documents with the
id
value of it’s root document — it’s highest ancestor, possibly itself.This field must be indexed (
indexed="true"
) but doesn’t need to be either stored (stored="true"
) or use doc values (docValues="true"
), however you are free to do so if you find it useful. If you want to useuniqueBlock(_root_)
field type limitation, then you should enable docValues.