【发布时间】:2016-11-21 00:20:44
【问题描述】:
我迷路了,需要你的建议。我有一个嵌套的 Solr 文档,其中包含多个级别的子文档。这是一个 JSON 示例,因此您可以看到完整的结构:
{
"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"
}]
}]
}
我想查询一个文档并检索嵌套结构。我尝试使用 ChildDocumentTranformerFactory 但它将结果展平为只是图书馆和所有其他文档作为孩子:
{
"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"
}
]
}
以下是我使用的查询参数:
q={!parent which='content_type:library'}
df=id
fl=*,[child parentFilter='content_type:library' childFilter='id:*']
wt=json
indent=true
从 Solr 读取嵌套结构的最佳方法是什么?我需要做一些刻面吗?
我正在使用 Solr 版本 5.2.1
【问题讨论】:
标签: solr