solr用子字段排序父级。忽略没有孩子价值观的父母

时间:2019-10-01 04:42:13

标签: solr

我正在使用 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"
  }
]

1 个答案:

答案 0 :(得分:0)

我们做到了如下 {!parent which = type:parent score = max v ='+ type:child {!func} sortField'} 通过降序排序时,上面的内容将直接放在sort = 当通过升序排序时,上述内容将被复制到$ computefield之类的替代内容中并添加到查询中。然后对计算字段使用def函数,使其具有默认值,例如99999