Hello,
I am sure there have been many discussions on the best way to do this, but I am
lost and need your advice. I have a nested Solr Document containing multiple
levels of sub-documents. Here is a JSON example so you can see the full
structure:
{
"id": "Test Library",
"description": "example of nested document",
"content_type": "library",
"authors": [{
"id": "author1",
"content_type": "author",
"name": "First Author",
"books": {
"id": "book1",
"content_type": "book",
"title": "title of book 1"
},
"shortStories": {
"id": "shortStory1",
"content_type": "shortStory",
"title": "title of short story 1"
}
},
{
"id": "author2",
"content_type": "author",
"name": "Second Author",
"books": {
"id": "book1",
"content_type": "book",
"title": "title of book 1"
},
"shortStories": {
"id": "shortStory1",
"content_type": "shortStory",
"title": "title of short story 1"
}
}]
}
I want to query for a document and retrieve the nested structure. I tried using
the ChildDocumentTranformerFactory but it flattened the result to be just
Library and all other documents as children:
{
"id": "Test Library",
"description": "example of nested document",
"content_type": "library",
"_childDocuments_":[
{"id": "author1",
"content_type": "author",
"name": "First Author"
},
{"id": "book1",
"content_type": "book",
"title": "title of book 1"
},
{
"id": "shortStory1",
"content_type": "shortStory",
"title": "title of short story 1"
},
{
"id": "author2",
"content_type": "author",
"name": "Second Author"
},
{
"id": "book1",
"content_type": "book",
"title": "title of book 1"
},
{
"id": "shortStory1",
"content_type": "shortStory",
"title": "title of short story 1"
}
]
}
Here are the query parameters I used:
q={!parent which='content_type:library'}
df=id
fl=*,[child parentFilter='content_type:library' childFilter='id:*']
wt=json
indent=true
What is the best way to read the nested structure from Solr? Do I need to do
some sort of faceting?
Thank you,
Jennifer Coston
P.S. I am using Solr version 5.2.1