gpt4 book ai didi

elasticsearch - 如何在ElasticSearch中按_version排序数据

转载 作者:行者123 更新时间:2023-12-02 23:22:20 24 4
gpt4 key购买 nike

因为我能够使用分数来对数据进行排序

    {
"version":true,
"_source":false,
"sort": [
{
"_score": {
"order": "desc"
}
}
],
"query": {
"match_all": {}

}
}

请让我知道如何使用_version做同样的事情。默认情况下,字段_version不支持Fielddata。所以可能是我缺少了一些东西。
是否有要查询版本的特定设置?
请帮忙!

最佳答案

您不能执行此操作,通常不必这样做。
看到这个线程:
https://discuss.elastic.co/t/filter-by--version-and-show--version-in-elasticsearch-query/22024/2

While using the _version might seem to work in certain cases, I would recommend to never use it for anything else than optimistic locking of updates. In particular, versions do not carry any meaning: they might look like the number of times a document has been modified but it is not always the case (for instance if you create a new document which has the same ID as a document that you just deleted, the version number of the new document will not be 1), and more importantly it is an implementation detail, this behaviour might change in the future.


_version字段未建立索引,因此您无法在查询中使用它。
您可以创建自定义版本字段并手动进行处理。

关于elasticsearch - 如何在ElasticSearch中按_version排序数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47789869/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com