Ajay Takur
Ajay Takur

Reputation: 6236

unable to find script [testfile] in cluster state in elastic search 8.9 v

I have created a file ie., testfile.painless

ctx._source.b_id=params.b_id;

and just placed the testfile.painless file in the config/scripts folder on cluster node and then tried with _update_by_query

{
    "script": {
        "id":  "testfile",
              "params": {
            "b_id": "1W"
        }

    },
    "query": {
        "bool": {
            "must": [
                {
                    "match": {
                        "a_core": "71"
                    }
                },
                {
                    "match": {
                        "cid": "3IM"
                    }
                }
            ]
        }
    }
}

When I ran the update query then I received with unable to find script [testfile] in cluster state

Upvotes: 0

Views: 275

Answers (1)

Val
Val

Reputation: 217474

Scripts cannot be stored in files anymore, you need to store them in the cluster state like this:

PUT _scripts/testfile
{
   "script": {
      "source": "....source code of your script..."
   }
}

And then you can run your update query like you do now.

Upvotes: 1

Related Questions