solr 排序父与子字段。忽略没有子值的父项
solr sorting parent with child field. ignoring parent with no child values
我正在使用 Solr 6.6,我们有一个包含子文档的父文档。我们正在对带有子字段的父项进行排序。排序工作正常,但是当父级没有子字段时,升序排序会将它们放在最前面。
我尝试将 sortMissingLast
作为 true
放在 child 的所有字段上,但它不起作用。
数据示例:
[
{
"id": "2",
"type": "product"
},
{
"id": "3",
"type": "product",
"childDocuments": [
{
"field1": 1,
"field2": 2,
"field3": 3,
"type": "price"
}
]
},
{
"id": "4",
"type": "product"
},
{
"id": "6",
"type": "product"
}
]
我们像下面那样做了
{!parent which=type:parent score=max v='+type:child {!func}sortField'}
当按降序排序时,上面将直接进入 sort=
当按升序排序时,上面的内容将被复制到 $computefield 之类的替代项中并添加到查询中。然后使用 def 函数为计算字段设置默认值,如 99999
我正在使用 Solr 6.6,我们有一个包含子文档的父文档。我们正在对带有子字段的父项进行排序。排序工作正常,但是当父级没有子字段时,升序排序会将它们放在最前面。
我尝试将 sortMissingLast
作为 true
放在 child 的所有字段上,但它不起作用。
数据示例:
[
{
"id": "2",
"type": "product"
},
{
"id": "3",
"type": "product",
"childDocuments": [
{
"field1": 1,
"field2": 2,
"field3": 3,
"type": "price"
}
]
},
{
"id": "4",
"type": "product"
},
{
"id": "6",
"type": "product"
}
]
我们像下面那样做了 {!parent which=type:parent score=max v='+type:child {!func}sortField'} 当按降序排序时,上面将直接进入 sort= 当按升序排序时,上面的内容将被复制到 $computefield 之类的替代项中并添加到查询中。然后使用 def 函数为计算字段设置默认值,如 99999