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
1 answer

How can I add element to array in ElasticSearch only if it doesn't exist?

How can I add an user to elastic search only if the user doesn't exists as well as user count? { "script" : { "source": "if (ctx._source.users != null){ctx._source.user_count += params.count; …
0
votes
0 answers

How to implement singleton in elastic painless script

I have a painless in elasticsearch, like: POST _scripts/painless/calculate-price { "script": "Map currencyMap = ['USD': 6.8, 'RUB': 0.122]; return doc['price'] * currencyMap[doc['currency']];" } I use this script to sort data, and size of…
mr.dot
  • 16
  • 4
0
votes
0 answers

Elasticsearch NEST API handle failed bulk updates

Updating a nested document using painless script. The document will be updated only when the condition is met. Trying to get noop response for the failed conditions but not able to get the response in dotNet's NEST bulk update API. How to achieve…
Muthu
  • 217
  • 5
  • 16
0
votes
0 answers

Painless script throwing connection error in py-elasticsearch

I have the following script search query: bdy = { "query": { "function_score": { "script_score": { "script": { "lang": "painless", "inline": "def test = "+test1+"; float total = 0; for (int i = 0; i <…
0
votes
1 answer

Week of the year aggregations using Painless

I'm facing a challenge while aggregating data by the "Week of Year" number. The use case is: The first day of the week is set as Sunday on my PC. Create a data range: Start='2018-06-24 Sunday' and End='2018-06-30 Saturday' Expected: I can only see…
Paulo Henrique PH
  • 324
  • 1
  • 4
  • 15
0
votes
1 answer

Convert Groovy date manipulation to Painless

I have a search query for Elasticsearch which uses a groovy inline script that I need to convert to Painless language mdt= doc.eventstartdate.value; dtevent = new DateTime(mdt).withTime(0,0,0,0).getMillis(); d = (dtevent
Ben
  • 155
  • 2
  • 12
0
votes
1 answer

Update nested string field

I am trying to update a field image.uri by _update_by_query: POST user/_update_by_query { "script": { "source": "ctx._source.image.uri = 'https://example.com/default/image/profile.jpg'", "lang": "painless" }, "query": { "bool": { …
Shaharyar
  • 12,254
  • 4
  • 46
  • 66
0
votes
1 answer

Elasticsearch error in getting a dynamic key's value

Partial mapping of one of my index is as follows: "schools": { "type": "object", "dynamic": true, "properties": {} } A sample schools object of an existing document is: "schools": { "8291": { "max": 11, "min": 11 }, "3546": { …
0
votes
1 answer

how to add a new field into a document using painless script

is there a way of creating a field in document within a painless script if it does not exists? i'm using something like: if(!ctx._source.tags.contains(....) but tags field may not be exists at document can it be done? thanks.
rontoher
  • 11
  • 1
  • 7
0
votes
1 answer

How to extract a param length from painless script

Hi i wonder how i can extract an array length from painless script? { "script": { "lang": "painless", "source": "what should be here???) { "params": { "plus": ["a","b","c"], //how to retrieve 3 as plus length? } }
rontoher
  • 11
  • 1
  • 7
0
votes
1 answer

How to perform elastic search _update_by_query using painless script - for complex condition

Can you suggest how to update documents (with a script - i guess painless) that based on condition fields? its purpose is to add/or remove values from the document so if I have those input documents: doc //1st { "Tags":["foo"], …
rontoher
  • 11
  • 1
  • 7
0
votes
1 answer

How to access Object inside a record while using script with ScriptedMetricAggregationBuilder elasticsearch?

"recordOne": { "properties": { "id": { "type": "integer" }, "recordtwo": { "properties": { "propertyone": { "type": "integer" }, "propertytwo":{ "type":"date" } } …
0
votes
0 answers

Add Items To Empty Object

I use go-mysql-elasticsearch to synchronize data between MySQL and ElasticSearch. This way, once an item is created in MySQL, it is automatically created in ElasticSearch. The mappings in ElasticSearch are created automatically, and that part…
Grim Reaper
  • 561
  • 4
  • 6
  • 22
0
votes
1 answer

Kibana: Mapp a field as a 'date' in Kibana

I filled ElasticSearch with dictionaries. I want to mapp one key to the date in Kibana: rep_ID:TZ14 createdOn:1,522,158,913,843 The value of the key'creatOn' should be the date. I tried the Painless Scripts in Dev Tools: PUT testindex { …
BaseFloor
  • 47
  • 1
  • 2
  • 5
0
votes
1 answer

Elasticsearch custom scoring function test null date values

I can't find anywhere examples of how to test null values in ES custom scoring functions. According to the doc the scripts are in groovy, according to the log the script is evaluated in painless, but even with that I'm left puzzled by some…
Cyril Duchon-Doris
  • 12,964
  • 9
  • 77
  • 164