微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Solr Cloud 上的 Solr 确定性随机数

如何解决Solr Cloud 上的 Solr 确定性随机数

我们希望随机结果与分页保持一致。我们尝试通过更改 randomSeed 函数修改 solr.RandomSortFieldType,基于此堆栈溢出问题:Solr: Random sort order after index version change

修改了这个函数删除了“(int)top.getVersion()”:

private static int getSeed(String fieldName,LeafReaderContext context) {
    final DirectoryReader top = (DirectoryReader) ReaderUtil.getTopLevelContext(context).reader();
    // calling getVersion() on a segment will currently give you a null pointer exception,so
    // we use the top-level reader.

    return fieldName.hashCode() + context.docBase + [Removed (int)top.getVersion()];
}

由于这没有产生预期的结果,我想知道是否可以通过创建一个存储字段来做一些更具决定性的事情,该字段是名为 (title_hash) 的文档标题字段的散列。然后我可以按如下方式替换 getSeed 函数

private static int getSeed(String fieldName,so
    // we use the top-level reader.

    return fieldName.hashCode() + getTitleHashValue();
}

是否可以从该函数中引用从字段类型继承的类中的文档字段值?如果是这样,我该怎么做,因为我不熟悉 Solr 的内部结构?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。