Questions tagged [elasticsearch-painless]

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'.

484 questions
0
votes
2 answers

Elasticsearch : How to do 'group by' with painless in scripted fields?

I would like to do something like the following using painless: select day,sum(price)/sum(quantity) as ratio from data group by day Is it possible? I want to do this in order to visualize the ratio field in kibana, since kibana itself doesn't have…
Elisavet
  • 41
  • 1
  • 6
0
votes
1 answer

Painless Script Error - "maximum number of statements that can be executed in a loop has been reached"

I have a painless script I'm trying to execute in elasticsearch to add new fields to an existing document based on the value of an existing field. Here is the source document I'm trying to update - "_source" : { "mpmNumber" : "4004749", …
raja
  • 61
  • 8
0
votes
0 answers

Is there a way to update a document with a Painless script without changing the order of unaffected fields?

I'm using Elasticsearch's Update by Query API to update some documents with a Painless script like this (the actual query is more complicated): POST ts-scenarios/_update_by_query?routing=test { "query": { "term": { "routing": { "value": "test"…
0
votes
1 answer

Elasticsearch max constraint on integer field?

I am trying to implement a system where one of the fields, (say count) is to incremented +1 via updates but is supposed to be constrained to have a maximum value of let's say 100. I have tried googling and have found nothing. Do these kind of…
0
votes
1 answer

elasticsearch ingest pipeline to rename dynamic fields

I have a fairly large document that i'm ingesting into elasticsearch (70-80 attributes). And there can be new fields that come in on a regular basis. I can use the rename operator to effectively rename each field but I was wondering if there was a…
0
votes
1 answer

Painless script to get time difference between two logs entries separated by a unique ID

I am trying to get time difference between two log entries like RequestExecuted and RequestReceived with a filed name MessageIdentifier. These valuse are linked by unique id named TransactionId. Below is my code to do the logic. int timetaken=0; …
0
votes
1 answer

Trying to update a nested geoip location field in elasticsearch

Here is what I've tried: POST orders/_update_by_query { "script" : "ctx._source.geoip += newElement", "params": { "newElement": { "location" : "[40.730610, -73.935242]" } }, "query": { "term": { …
cluis92
  • 664
  • 12
  • 35
0
votes
1 answer

Partially update a document using scripting and add missing fields

I would like to know if It's possible to update a document using a partial document, and use a script to perform another action, for example if I add data1 and then add data2, I want my document to look like final_result. I want everything to be…
Gomeisa
  • 97
  • 1
  • 9
0
votes
2 answers

Painless access a value in an ArrayList

Trying to work out how to access an item in an ArrayList. I have the values in _source: "session_id" : [ "19a7ec8d", "19a7ec8d" ], As they are all duplicates (due to a faulty Grok script), I want to get rid of the duplicates: I cannot…
Rowan Smith
  • 1,815
  • 15
  • 29
0
votes
2 answers

Using nested values in script_score

I am attempting to use nested values in a script score, but I am having issues making it work, because I am unable to iterate over the field by accessing it through doc. Also, when I try to query it in Kibana like _type:images AND _exists_:colors,…
Severin
  • 962
  • 5
  • 21
0
votes
3 answers

Elasticsearch remove a field from an object of an array in a dynamically generated index

I'm trying to delete fields from an object of an array in Elasticsearch. The index has been dynamically generated. This is the mapping: { "mapping": { "_doc": { "properties": { "age": { "type": "long" }, …
Mark
  • 343
  • 3
  • 11
0
votes
1 answer

Elasticsearch - Install stored scripts into filesystems

I hace a EL 7.6.1 cluster with 4 nodes. I want install some stored scripts. Into documentation (https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-using.html and) I only read about send a POST with somethint like…
icalvete
  • 987
  • 2
  • 16
  • 50
0
votes
1 answer

How to retrieve all existing indeces in painless

I'm wanting to retrieve the number of indices in my ES cluster from within a scripted field of an aggregation. I know you can access some context values with ctx._source but does anyone know how to get the total number of indeces from my…
Louis Hulot
  • 357
  • 2
  • 13
0
votes
1 answer

Elasticsearch: Update/upsert an array field inside a document but ignore certain existing fields

GET _doc/1 "_source": { "documents": [ { "docid": "ID001", "added_vals": [ { "code": "123", "label": "Abc" }, { "code": "113", …
Sid
  • 765
  • 5
  • 29
  • 57
0
votes
1 answer

Painless (Elasticsearch) can't use keyword - script error

I'm trying to create a scripted field in Kibana, which checks whether the field "Direction" is "I" or not. if (doc['Direction'].value != "I") {return 1;} else {return 0;} But for some reason, it won't work. With all other fields, that aren't…