Not able to execute painless scripts

I am quite new to painless or any kind of scripting in elastic.

I wanted to know how do i execute a script in elastic.

Scenario: I have a mapping.json, with all the fields to be indexed in elastic. I am using elasticsearchjs npm module as my code is in typescript. So to execute the script which is basically adding a new field to an existing document. Looks somewhat like this "ctx._source.name = SZ_MK.pdf".

Now my question is where do i add -->

      "inline": "ctx._source.name = SZ_MK.pdf",
      "lang": "painless"
    }

so that it gets executed is it within mappings or somewhere else?

It depends on what you are trying to do. If you want to update a single document, you can use the update api. If you are trying to update all of your documents, then look at update_by_query. And if you want to modify documents as they are indexed then look at ingest scripts.

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