Comments
Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability This functionality is generally available and ready for production usage. Serverless interfaces and procedures might differ from classic Elastic Stack deployments. The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability This functionality is generally available and ready for production usage. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.
Serverless
Generally available
Stack
Generally available
Comments are used to explain or annotate code and make it more readable. They are ignored when the script is executed, allowing you to add notes or temporarily disable code sections without affecting the functionality.
Painless supports two types of comments: single-line comments and multi-line comments.
Single-line comments start with // and continue to the end of the line. Everything after // on that line is ignored by the compiler.
SINGLE_LINE_COMMENT: '//' .*? [\n\r];
// This is a single-line comment
int value = 10;
int price = 100;
- Comment at the end of a line
Multi-line comments start with /* and end with */. Everything between these markers is ignored, even if it spans multiple lines.
MULTI_LINE_COMMENT: '/*' .*? '*/';
/* This is a
multi-line comment
spanning several lines */
int total = price * quantity;
/* You can also use multi-line comments
to temporarily disable code blocks:
int debugValue = 0;
debugValue = calculateDebug();
*/
int result = /* inline comment */ calculateTotal();
Use comments to:
- Explain complex logic or business rules
- Document function parameters and return values
- Provide context data transformations
- Temporarily disable code during development
Good comments explain why something is done, not just what is being done. The code itself should be clear enough to show what it does.