Es query statement asking for help

now there is a data with the following fields

id expired create_time

the requirement is to filter out creation time + expiration time (seconds) < system current time . If it is a sql statement, it is very simple:

select * from table where DATE_ADD(create_time,INTERVAL expired SECOND) < now();

how should I query in es?

Mar.21,2022

you first subtract the expiration time from the system time, and then judge that this time is not compared with the creation time in the es library


has been solved, use script to query:

GET /.../_search
{
  "query": {
    "bool": {
      "must": [
        {
          "script": {
            "script": {
              "source": "return (doc['create_time'].value.getMillis() + doc['expired'].value * 1000) < new Date().getTime()"
            }
          }
        }
      ]
    }
  },
  "size": 20
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e94594-14cc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e94594-14cc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?