search - How to get Parent Document of matching Child Document in Query?
问题描述
I have set up Solr so that if I index a "Listing" document, The Listing object gets indexed as a parent document, and the "Products" the Listing has gets indexed as children documents, to achieve documents in the following format as separate documents:
// SHOW ALL DOCUMENTS
[{ //child 1
"id":"361",
"product.listing_id":"360",
"product.product":"Classic Tee",
"product.colors":["Orange","Pink"],
"product.sizes":["S","M"],
"product.doc_type":"product"
},
{ //child 2
"id":"362",
"product.listing_id":"360",
"product.product":"Yoga Pants",
"product.colors":["Black"],
"product.sizes":["S","M"],
"product.doc_type":"product"
},
{ //parent
"id":"360",
"name":"Listing1",
"url":"listing.com",
"doc_type":"Listing"
}]
I've figured out how to use the ChildDocTransformerFactory to retrieve the children of "Listing" ex) query "Listing1", get back all documents above.
I achieve this by adding the following to my fl's: "[parent childFilter=product.doc_type:product parentFilter=doc_type:listing]"
However, that's the opposite of what I want, as I'm trying to query for the children fields and only want the matching child along with its parent, like so:
Query for "Pink", get back documents IDs 361 and 360.
Is this possible to achieve?
解决方案
推荐阅读
- maximo - IBM Maximo - 服务请求应用程序上的空报告日期必填字段
- swift - 如何在 Flutter 中启用对现有项目的 Swift 支持
- r - 控制动画的速度
- python - 为什么我面对空图而没有任何错误?
- google-authentication - GOOGLE_APPLICATION_CREDENTIALS 在环境中定义但在身份验证时无法识别
- python - 将数据帧结果与 DatetimeIndex 索引相结合
- jquery - $ 未定义,但它仍然可以完美运行
- javascript - 更新状态时无法在现有状态转换期间更新?
- angular - 链 Observables 和 Promise
- angular6 - 如何根据全局/父组件的条件设置多个角度材料日期选择器的状态无效