Skip to content

Support multi-line """-separated Painless scripts  #75

@gabriel-r

Description

@gabriel-r

When the multiline syntax with """ separators is used, the highlighter reports it as an error.
Initially I thought it it's just because of the " inside, but it's not (just) that. It seems the highlighter is using JSON rules, while painless is more permissive

This makes it very hard for script editing.

Example code

  "script_fields": {
    "flattened_events": {
      "script": {
        "lang": "painless",
        "source": """
        Map events = new HashMap();
        for (def transaction : doc['external_card_transactions']) {
          Map transData = new HashMap();
          transData.put("created_at", transaction['created_at'].value);
          transData.put("type", transaction['type'].value);
          transData.put("amount", transaction['amount'].value);
          transData.put("currency_code", transaction['currency_code'].value);
          transData.put("original_amount", transaction['currency_conversion.network.original_amount'].value);
          transData.put("original_currency_code", transaction['currency_conversion.network.original_currency_code'].value);
          transData.put("conversion_rate", transaction['currency_conversion.network.conversion_rate'].value);
          events.put(transaction, transData);
        }
        return events.toString();
        """
      }
    }
  },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions