- 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
Using ingest processors in Painless
editUsing ingest processors in Painless
editSome ingest processors expose behavior through Painless methods that can be called in Painless scripts that execute in ingest pipelines.
Method usage
editAll ingest methods available in Painless are scoped to the Processors
namespace. For example:
POST /_ingest/pipeline/_simulate?verbose { "pipeline": { "processors": [ { "script": { "lang": "painless", "source": """ long bytes = Processors.bytes(ctx.size); ctx.size_in_bytes = bytes; """ } } ] }, "docs": [ { "_source": { "size": "1kb" } } ] }
Ingest methods reference
editByte conversion
editUse the bytes processor to return the number of
bytes in the human-readable byte value supplied in the value
parameter.
long bytes(String value);
Lowercase conversion
editUse the lowercase processor to convert the
supplied string in the value
parameter to its lowercase equivalent.
String lowercase(String value);
Uppercase conversion
editUse the uppercase processor to convert the
supplied string in the value
parameter to its uppercase equivalent.
String uppercase(String value);
JSON parsing
editUse the JSON processor to convert JSON strings to structured
JSON objects. The first json
method accepts a map and a key. The processor converts
the JSON string in the map as specified by the key
parameter to structured JSON content.
That content is added directly to the map
object.
The second json
method accepts a JSON string in the value
parameter and
returns a structured JSON object.
void json(Map<String, Object> map, String key); Object json(Object value);
You can then add this object to the document through the context object:
Object json = Processors.json(ctx.inputJsonString); ctx.structuredJson = json;
URL decoding
editUse the URL decode processor to URL-decode the string
supplied in the value
parameter.
String urlDecode(String value);
URI decomposition
editUse the URI parts processor to decompose the URI string
supplied in the value
parameter. Returns a map of key-value pairs in which the key is
the name of the URI component such as domain
or path
and the value is the
corresponding value for that component.
String uriParts(String value);
Network community ID
editUse the community ID processor to compute the network community ID for network flow data.
String communityId(String sourceIpAddrString, String destIpAddrString, Object ianaNumber, Object transport, Object sourcePort, Object destinationPort, Object icmpType, Object icmpCode, int seed) String communityId(String sourceIpAddrString, String destIpAddrString, Object ianaNumber, Object transport, Object sourcePort, Object destinationPort, Object icmpType, Object icmpCode)
On this page