在solr 6.6.0中,我想使用嵌套对象作为特定键。
所以假设我有一份文件如下:
{
"ID": "16_nl",
"countryIso": "AUS",
"regionId": 30,
"name": "test",
"placeId": 50,
"eventID": 100,
"facilities": [12],
"created": "2017-11-30T11:00:36.717Z",
"modified": "2017-11-30T11:00:36.717Z"
}
但是现在,我想用上面的关键“提案”在上面的文件中添加子文件
{
"ID": "16_nl",
"countryIso": "AUS",
"regionId": 30,
"name": "test",
"placeId": 50,
"eventID": 100,
"facilities": [12],
"proposal": [{
"duration": 55,
"price" : 300,
"status":"VISIBLE"
}],
"created": "2017-11-30T11:00:36.717Z",
"modified": "2017-11-30T11:00:36.717Z"
}
我怎样才能在Solr中做到这一点?
我已经浏览了http://yonik.com/solr-nested-objects/和其他文件,我有以下问题
答案 0 :(得分:1)
您必须在特殊键“_childDocuments_”下列出子文档。在Apache Solr参考指南中,您将找到此示例,并提示“请注意特殊的_childDocuments_键需要在JSON中指示嵌套文档”:
{
"id": "1",
"title": "Solr adds block join support",
"content_type": "parentDocument",
"_childDocuments_": [{
"id": "2",
"comments": "SolrCloud supports it too!"
}]
}
请注意子文档必须包含的id字段。
然后使用Block Join Children Query Parser按父属性查找子项,使用Block Join Parent Query Parser按子属性查找父项。见https://lucene.apache.org/solr/guide/6_6/other-parsers.html#OtherParsers-BlockJoinQueryParsers