Import script from file

"script": {
                "source": " very big script code",

i have a script with huge source code! is there any way to import script from external file?
i want to write script code with vscode and save in a file! and then import to my query.


Unfortunately this is currently not possible, however you can use """ for multiline statements like this.

GET _search
{"query": {
    "function_score": {
      "script_score": {
        "script": {
          "lang": "painless",
          "source": """
            int total = 0;
            total += 2;
            return total;

Or you can remove newlines of you code before pasting it. But I do agree that importing a file would be more comfortable.


1 Like

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