0

我有一个结构如下的 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 参数来实现这一点?谢谢

4

1 回答 1

1

根据 EricLavault 的建议,我修改了索引以在索引中包含对象的类型,如下所示 -

{
    "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 的书

于 2022-01-28T16:24:08.917 回答