AntonShuvaev / elasticsearch4idea

Elasticsearch Plugin for JetBrains IDEs
https://plugins.jetbrains.com/plugin/14512-elasticsearch
59 stars 8 forks source link

Add syntax highlighter to the painless scripts. #126

Open spaduret opened 1 year ago

spaduret commented 1 year ago

Is your feature request related to a problem?

At the moment painless script is not highlighted and rendered as a string:

POST _scripts/test_script
{
  "script": {
    "lang": "painless",
    "source": """
        Debug.explain("test");
      """
  }
}

Same for scripted query:

GET index/_search
{
  "query": {
    "script": {
      "script": {
        "source": """
          doc['field'].value > 0;
        """
      }
    }
  }
}

Describe the solution you'd like

Would like to have a syntax highlighter added to the painless scripts. At least what is available in Kibana.

Also, it would be great to have a code-completion feature, at least for JAVA namespaces.

Additional context

Code completion can be added also to document reference using index mapping. I understand that it might be hard to calculate the context, but this can 100% work in runtime_mappings and stored scripts (just need to connect with an index somehow).

POST _scripts/test_script
{
  "script": {
    "lang": "painless",
    "source": """
        ctx._source... // here can use index mapping
      """
  }
}
AntonShuvaev commented 1 year ago

Thank you for the suggestion. I'll consider implementing this in the future.