You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by sara hajili <ha...@gmail.com> on 2018/07/14 11:26:52 UTC

solr nested schema

hi
i need add nested document in solr . how can i do this ?
how add nested document field in schema ?
for example i need to add this :
{
  "id":12,
   'topic":[ {
                   code:1,
                    name:"hi"
                },
                {
                    code:2,
                     name:"hi"
                }
              ]
}

Re: solr nested schema

Posted by Shawn Heisey <ap...@elyograg.org>.
On 7/14/2018 6:46 AM, sara hajili wrote:
> i need to have nested object to solr document , and query in nested objects
> and children. i create this schema :
> <field name="topic" type="text_fa" indexed="true" stored="true" multiValued=
> "true" termVectors="true"/> <field name="topic.code" type="text_general"
> indexed="true" stored="true" multiValued="true" /> <field name="topic.name"
> type="text_fa" indexed="true" stored="true" multiValued="true"/>
>   and add this doc :
> {
> "id":12,
> "topic":{"code":12,"name":"hi"}
> }
>
> this file added completly but have a probelm in search. i didn't get any
> result when is search : "topic.code:12"
> i didn't get any result from solr.

Parent/Child document support doesn't work that way.

It seems that what you actually want is to send a nested structure and 
have Solr parse a complex field definition into multiple fields.  Solr 
isn't going to do this for you.  You'll need to handle this in your 
indexing application.  When your application gets results from Solr, it 
can recreate the nested structure to show to the user.

A child document is a completely separate document.  That document has a 
field which links it to another document that gets indexed at the same 
time -- its parent.

I have no idea what Solr would do when indexing the json that you sent 
it.  As you've noticed, it doesn't do what you expected.

Thanks,
Shawn


Re: solr nested schema

Posted by sara hajili <ha...@gmail.com>.
i need to have nested object to solr document , and query in nested objects
and children. i create this schema :
<field name="topic" type="text_fa" indexed="true" stored="true" multiValued=
"true" termVectors="true"/> <field name="topic.code" type="text_general"
indexed="true" stored="true" multiValued="true" /> <field name="topic.name"
type="text_fa" indexed="true" stored="true" multiValued="true"/>
 and add this doc :
{
"id":12,
"topic":{"code":12,"name":"hi"}
}

this file added completly but have a probelm in search. i didn't get any
result when is search : "topic.code:12"
i didn't get any result from solr.
what is my problem?
schema? adding doc ? or query ?
On Sat, Jul 14, 2018 at 4:24 PM Andrea Gazzarini <a....@sease.io>
wrote:

> Hi,
> Please expand a bit your needs, because the answer to your question could
> be different.
>
> Specifically: is that nesting needed only for visualization purposes? Could
> you please expand your access pattern (i.e. queries requirements)?
>
> Even if Solr supports nested documents (just google "Solr nested
> documents") , depending on the answers above, it could be something that
> you don't need.
>
> Best,
> Andrea
>
> Il sab 14 lug 2018, 13:27 sara hajili <ha...@gmail.com> ha scritto:
>
> > hi
> > i need add nested document in solr . how can i do this ?
> > how add nested document field in schema ?
> > for example i need to add this :
> > {
> >   "id":12,
> >    'topic":[ {
> >                    code:1,
> >                     name:"hi"
> >                 },
> >                 {
> >                     code:2,
> >                      name:"hi"
> >                 }
> >               ]
> > }
> >
>

Re: solr nested schema

Posted by Andrea Gazzarini <a....@sease.io>.
Hi,
Please expand a bit your needs, because the answer to your question could
be different.

Specifically: is that nesting needed only for visualization purposes? Could
you please expand your access pattern (i.e. queries requirements)?

Even if Solr supports nested documents (just google "Solr nested
documents") , depending on the answers above, it could be something that
you don't need.

Best,
Andrea

Il sab 14 lug 2018, 13:27 sara hajili <ha...@gmail.com> ha scritto:

> hi
> i need add nested document in solr . how can i do this ?
> how add nested document field in schema ?
> for example i need to add this :
> {
>   "id":12,
>    'topic":[ {
>                    code:1,
>                     name:"hi"
>                 },
>                 {
>                     code:2,
>                      name:"hi"
>                 }
>               ]
> }
>