[英]elastic search query to compare two date fields while fetching
I have 2 date fields updated_date
and creation date
. 我有2个日期字段
updated_date
和creation date
。 I'm trying to build a query using boolquery or searchbuilder where I need all records where updation_date is greater than creation date 我正在尝试使用boolquery或searchbuilder建立查询,其中需要updation_date大于创建日期的所有记录
tried with range query but it didn't work 尝试了范围查询,但没有用
Use script filter, Use isAfter() for greater than in painless script. 使用脚本过滤器,使用isAfter()的效果要比无痛苦的脚本更大。
"query": {
"bool": {
"filter": {
"script": {
"script": "doc['update_date'].date.isAfter(doc['created_date'].date)"
}
}
}
}
Not sure if you are aware about head plugin https://github.com/mobz/elasticsearch-head 不知道您是否知道头部插件https://github.com/mobz/elasticsearch-head
Use the structured query tab to create the query. 使用结构化查询选项卡创建查询。 Select the check box 'Show query source' to see the generated query script.
选中“显示查询源”复选框以查看生成的查询脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.