[英]how can i make this query in Elasticsearch?
Postgresql query like this : 像这样的Postgresql查询:
select * from equipment where production_day < now() + interval '-1 years' * endurance_period + interval '1 month'
endurance_period is column name in table. endurance_period是表中的列名。 How can I convert this query to Query DSL(JSON) in ElasticSearch?
如何在ElasticSearch中将此查询转换为查询DSL(JSON)?
you can do date time manipulations for fields on date fields 您可以对日期字段上的字段进行日期时间操作
Small example of using date math/function manipulations inside the range filter 在范围过滤器内使用日期数学/函数操作的小例子
{
"range" : {
"date" : {
"gte" : "now-1d/d",
"lt" : "now/d"
}
}
}
so your query may look more or less like this 所以你的查询可能看起来或多或少像这样
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [{
"range": {
"created_at": {
"lte": "now-1*3d/d"
}
}
}]
}
}
}
}
}
you can extend the gte equation to match your search filter criteria. 您可以扩展gte方程以匹配您的搜索过滤条件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.