Using Painless Script with Lucene Query in ElasticSearch

I needed to create a function in Painless to perform multiple field checks of a document and return if a value is in a range of 0 to 2. This Painless script uses parameters with names, such as 'current_timestamp', which are entered manually.

Is possible use this script in a search in ElasticSearch when it is made using only Lucene Query and not the default JSON of the ES?

I tried to perform a search that way, but it doesn't work.

    "from": 0,
    "size": 30,
    "sort": {
        "id": {
            "order": "desc"
    "query": {
        "query_string": {
            "query": "isvalid({current_timestamp:1538081255011}):2"

It's not possible to do this inside a lucene query. You will need to use a script query.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.