Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gabriel-r opened this issue Dec 5, 2023 · 0 comments
Open

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

gabriel-r opened this issue Dec 5, 2023 · 0 comments

Comments

@gabriel-r
Copy link

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();
        """
      }
    }
  },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant