- Painless Scripting Language: other versions:
- Painless Guide
- Painless Language Specification
- Painless contexts
- Context example data
- Runtime fields context
- Ingest processor context
- Update context
- Update by query context
- Reindex context
- Sort context
- Similarity context
- Weight context
- Score context
- Field context
- Filter context
- Minimum should match context
- Metric aggregation initialization context
- Metric aggregation map context
- Metric aggregation combine context
- Metric aggregation reduce context
- Bucket script aggregation context
- Bucket selector aggregation context
- Analysis Predicate Context
- Watcher condition context
- Watcher transform context
- Painless API Reference
- Shared API
- Aggregation Selector API
- Aggs API
- Aggs Combine API
- Aggs Init API
- Aggs Map API
- Aggs Reduce API
- Analysis API
- Bucket Aggregation API
- Field API
- Filter API
- Ingest API
- Interval API
- Moving Function API
- Number Sort API
- Painless Test API
- Processor Conditional API
- Score API
- Script Heuristic API
- Similarity API
- Similarity Weight API
- String Sort API
- Template API
- Terms Set API
- Update API
- Watcher Condition API
- Watcher Transform API
- Xpack Template API
Literals
editLiterals
editUse a literal to specify a value directly in an operation.
Integers
editUse an integer literal to specify an integer type value in decimal, octal, or
hex notation of a primitive type int
, long
, float
,
or double
. Use the following single letter designations to specify the
primitive type: l
or L
for long
, f
or F
for float
, and d
or D
for double
. If not specified, the type defaults to int
. Use 0
as a prefix
to specify an integer literal as octal, and use 0x
or 0X
as a prefix to
specify an integer literal as hex.
Grammar
INTEGER: '-'? ( '0' | [1-9] [0-9]* ) [lLfFdD]?; OCTAL: '-'? '0' [0-7]+ [lL]?; HEX: '-'? '0' [xX] [0-9a-fA-F]+ [lL]?;
Examples
Floats
editUse a floating point literal to specify a floating point type value of a
primitive type float
or double
. Use the following
single letter designations to specify the primitive type: f
or F
for float
and d
or D
for double
. If not specified, the type defaults to double
.
Grammar
DECIMAL: '-'? ( '0' | [1-9] [0-9]* ) (DOT [0-9]+)? EXPONENT? [fFdD]?; EXPONENT: ( [eE] [+\-]? [0-9]+ );
Examples
Strings
editUse a string literal to specify a String
type value with
either single-quotes or double-quotes. Use a \"
token to include a
double-quote as part of a double-quoted string literal. Use a \'
token to
include a single-quote as part of a single-quoted string literal. Use a \\
token to include a backslash as part of any string literal.
Grammar
STRING: ( '"' ( '\\"' | '\\\\' | ~[\\"] )*? '"' ) | ( '\'' ( '\\\'' | '\\\\' | ~[\\'] )*? '\'' );
Examples
-
String literals using single-quotes.
'single-quoted string literal' '\'single-quoted with escaped single-quotes\' and backslash \\' 'single-quoted with non-escaped "double-quotes"'
-
String literals using double-quotes.
"double-quoted string literal" "\"double-quoted with escaped double-quotes\" and backslash: \\" "double-quoted with non-escaped 'single-quotes'"
Characters
editCharacter literals are not specified directly. Instead, use the
cast operator to convert a String
type value
into a char
type value.
On this page