Painless is a scripting language that is purpose-built for Elasticsearch. It was introduced with Elasticsearch 5.0. Painless can be used anywhere in Elasticsearch where scripts can normally be run by specifying the 'lang' parameter as 'painless'.
Questions tagged [elasticsearch-painless]
484 questions
1
vote
0 answers
Elasticsearch painless script orders array items
I need a help about getting an array item with indice ([0] e.g.) in elasticsearch. Whatever painless or scriptless behaviour.
Here is my little test mapping, document and results;
"mappings": {
"tip": {
"properties": {
…

btungut
- 23
- 3
1
vote
2 answers
extract text from field arrays
One of the fields called "resources" has the following 2 inner documents.
{
"type": "AWS::S3::Object",
"ARN": "arn:aws:s3:::sms_vild/servers_backup/db_1246/db/reports_201706.schema"
},
{
"accountId": "934331768510612",
"type":…

shantanuo
- 31,689
- 78
- 245
- 403
1
vote
1 answer
ElasticSearch find indexed objects with distinct nested list elements from specified terms
Let's suppose we have a student with a (nested) list of scores as follows:
public class Student
{
public string FullName { get; set; }
public List Scores { get; set; } = new List();
}
public class Score
{
public int Value {…

skipper
- 171
- 2
- 11
1
vote
1 answer
Comparing arrays with Painless
Is there a quick way in Painless to compare the values of one array to another? I'm trying to avoid a long loop statement. I'm looking for something that will evaluate as the following two items:
ARRAY[1,4,3] contains ARRAY[3,1] = true
ARRAY[2,7]…

EricPSU
- 163
- 1
- 7
1
vote
1 answer
Elasticsearch: Get object index with Painless script
I have a nested type and I need to get the index of a specific object to perform an update:
{
"_index": "asset_en_v1",
"_type": "note",
"_id": "23217",
"_version": 24,
"found": true,
"_source": {
"user_id": "11",
"title":…

Wayne Smallman
- 1,690
- 11
- 34
- 56
1
vote
1 answer
How to add "updatedAt" timestamp to elasticsearch documents
I want to ensure that all documents of a certain doc_type have a "updatedAt" timestamp (ISO 8601) that gets updated whenever the document is updated. It needs to be a server-side timestamp as I don't know if I can trust that all of the clients…

David Morton
- 1,744
- 2
- 15
- 20
1
vote
0 answers
ElasticSearch - Script - Loop - Painless
\I am not able to execute LOOP on subdocuments in Painless.
This is just one example scenario created to run LOOP the scenario is another (this case could be run filter but the problem is the loop in subdocuments).
GET /_stats
GET…

Thiago Silva
- 11
- 1
- 3
1
vote
1 answer
ElasticSearch/Painless: How do I access/sum all values in an object
I've been looking at aggregations, and at scripting using painless, and I am not able to figure out how to iterate/sum over all values in an object.
Example:
My mapping looks like
"field1": {
"properties": {
"subfield1": {
"type":…

shashwat
- 992
- 1
- 13
- 27
1
vote
1 answer
Elastic search painless script issue with long type
I am currently using Elastic search 5.2 and trying to perform upsert
operation using the following rest api:
http://ip:9200/indexname/typename/id/_update
Json Payload:
{
"script" : {
"inline": "ctx._source.size +=params.size",
"lang":…

Rock
- 69
- 10
1
vote
2 answers
elasticsearch script_score custom score function: how to replace missing values?
I am looking at elasticsearch's documentation for how to create a script for a custom score function which uses fields that are not queried for scoring at this link.
From what I can see you build a script function like so:
"script_score" : {
…

user3494047
- 1,643
- 4
- 31
- 61
1
vote
1 answer
kibana 5 scripted field for regex match
I want to add scritpted field in Kibana 5 to get stored proc name from message. To be able to visualize number of errors per each SP.
I have field "message" where I can see error text:
"[2017-02-03 05:04:51,087] @…

Kristina Kucherova
- 31
- 1
- 4
1
vote
1 answer
Elasticsearch array field is sorted when accessed within Painless scripting language
I have an integer array field, for example, my_integer_array.
I stored [3, 4, 1, 2] on the field via client and I can see that [3, 4, 1, 2] is successfully set on the document's my_integer_array field via Kibana.
But whenever I try to access the…

June
- 2,107
- 4
- 22
- 33
1
vote
1 answer
ElasticSearch Painless Script Not Working
I am trying to use the following Painless script query in one of my applications, but it does not seem to be working. Any problem with the syntax? I noticed that the part that does not really work is this Math.max(doc["level"].value, 1) - 1. Please,…

geeko
- 2,649
- 4
- 32
- 59
1
vote
1 answer
Truncate part of an existing field value to a new field using painless?
I'm having a timestamp field which has a value something like this , where pretty much all the values would be in the same format:
January 1st 2017, 05:29:59.000
What I need is to trim part of the above which should look:
January 1st 2017
So what I…

Kulasangar
- 9,046
- 5
- 51
- 82
1
vote
2 answers
Elasticsearch script query get parameter by field value
I am trying to filter results with script query.
I can access parameter values with hardcoded field value like this:
"script": "doc['price'].value * params.1000 > 4000",
"params": {"1000": "1.75"}
But if I try to get field value with doc…

Pusic
- 41
- 1
- 7