我有一个Solr4索引,表示内容之间的child-gt;父关系以及以下相关字段:
item_id 是关系ID, im_endpoints_source_node $ nid 是父文档ID的多值字段, im_endpoints_target_node $ nid 是子文档ID的多值字段。
每份文件可能有几个孩子和几个父母。
我想选择特定文件的所有祖先或后代关系。
让我们假设我有一个结构:
1 > 30
1 > 11
11 > 121
11 > 126
126 > 134
我能够通过以下选择查询获得所有直接父关系:
/select?fq=im_endpoints_source_node$nid:1
其中给出了以下结果:
{
"response": {
"numFound": 2,
"start": 0,
"docs": [
{
"id": "child_relation_index-9",
"index_id": "child_relation_index",
"item_id": "9",
"is_rid": 9,
"bs_field_relation_inactive": false,
"ss_search_api_language": "und",
"im_endpoints_source_node$nid": [
1
],
"im_endpoints_target_node$nid": [
30
],
"timestamp": "2013-09-24T13:03:44.739Z"
},
{
"id": "child_relation_index-13",
"index_id": "child_relation_index",
"item_id": "13",
"is_rid": 13,
"bs_field_relation_inactive": false,
"ss_search_api_language": "und",
"im_endpoints_source_node$nid": [
1
],
"im_endpoints_target_node$nid": [
11
],
"timestamp": "2013-09-24T13:03:44.739Z"
}
]
}
}
与祖先关系的第二级(祖父母关系)与以下选择查询:
/select?fq={!join from=im_endpoints_target_node$nid to=im_endpoints_source_node$nid}im_endpoints_source_node$nid:1
其中给出了以下结果:
{
"response": {
"numFound": 2,
"start": 0,
"docs": [
{
"id": "child_relation_index-18",
"index_id": "child_relation_index",
"item_id": "18",
"is_rid": 18,
"bs_field_relation_inactive": false,
"ss_search_api_language": "und",
"im_endpoints_source_node$nid": [
11
],
"im_endpoints_target_node$nid": [
121
],
"timestamp": "2013-09-24T13:03:44.739Z"
},
{
"id": "child_relation_index-19",
"index_id": "child_relation_index",
"item_id": "19",
"is_rid": 19,
"bs_field_relation_inactive": false,
"ss_search_api_language": "und",
"im_endpoints_source_node$nid": [
11
],
"im_endpoints_target_node$nid": [
126
],
"timestamp": "2013-09-24T13:03:44.739Z"
}
]
}
}
有没有办法在一个查询中获取文档的所有祖先(从1级到N级)?
仅供参考:此索引是使用Drupal的Search API Solr模块与Relation模块一起创建的。它包含超过300k的关系,约500k文件。
任何帮助都将受到高度赞赏。