[英]Solr - Search parent having multiple child documents
我有一個結構如下的 Solr 索引。
{
"id": "1",
"bookName_s": "Core Concepts",
"bookDescription_s": "This is the description",
"isbn_s": "ABCD:123",
"reviews": [
{
"id": "2",
"Name_s": "review1",
"detail_s": "sample review"
}
],
"students": [
{
"id": "3",
"Name_s": "student1",
"student_s": "test student"
}
]
}
我如何搜索具有 Name_s 為“review1”的審閱者和 Name_s 為“學生”的學生的父母。
我嘗試了如下所示的父塊鏈查詢,但似乎沒有任何效果-
q=({!parent which="*:* -_nest_path_:*"}(+_nest_path_:\/reviews +Name_s:*rev*)) AND ({!parent which="*:* -_nest_path_:*"}(+_nest_path_:\/students +Name_s:*stu*))
q=({!parent which="*:* -_nest_path_:*"}(+_nest_path_:\/reviews +Name_s:*rev*)(+_nest_path_:\/students +Name_s:*stu*))
有沒有辦法我可以使用 q 運算符而不是 fq 參數來實現這一點? 謝謝
根據 EricLavault 的建議,我修改了索引以在索引中包含 object 的類型,如下所示 -
{
"id": "1",
"bookName_s": "Core Concepts",
"bookDescription_s": "This is the description",
"isbn_s": "ABCD:123",
"type_s":"book"
"reviews": [
{
"id": "2",
"Name_s": "review1",
"detail_s": "sample review",
"type":"review"
}
],
"students": [
{
"id": "3",
"Name_s": "student1",
"type":"student",
"student_s": "test student"
}
]
}
以下查詢有效。
{!parent which="type:book"}(type:review AND Name_s:review1) OR (type:student AND Name_s:student1)
返回所有帶有 review1 和 student1 的書
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.