如何在Elasticsearch中按两个字段的算术差异进行排序

huangapple 未分类评论44阅读模式
英文:

How to sort in Elasticserch by the arithmetic difference of two fields

问题

可以按照两个字段之间的算术差异对Elasticsearch数据进行排序吗?
数据如下所示:

{
    "id": "123",
    "price": 500.0,
    "discount": 10.0
}

我需要按照 price - discount 的差异对数据进行排序。
总体上说,这种排序是可行的吗?

我还对通过Java API实现它感兴趣。

英文:

Is it possible to sort Elasticserch data by the arithmetic difference between the two fields?
The data are like this:

{
	"id": "123",
	"price": 500.0,
	"discount": 10.0,
}

And I need to sort the data by the difference price - discount.
Is it possible in general?

I am also interested in the implementation of it via Java API.

huangapple
  • 本文由 发表于 2020年7月27日 17:08:08
  • 转载请务必保留本文链接:https://java.coder-hub.com/63112084.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定