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
0 answers

Elasticsearch painless count much slower than external program

I'm trying to count the number of items in a field and save it. With 16 million records, running the following painless query takes 90 minutes: { "script": { "source": " if(ctx._source.myfield.empty) { ctx._source.myfield_count=0 } …
Hooked
  • 84,485
  • 43
  • 192
  • 261
0
votes
0 answers

Is it possible to compare and update record using logstash?

I am trying to generate the summary from some data available in Elasticsearch using Logstash in which i have fields like loan_account_no., customer_id, batch, rank, channel and many more. I am creating the primary key (_id) by the combining…
0
votes
0 answers

Elasticsearch. Painless script to search based on the last result

Let's see if someone could shed a light on this one, which seems to be a little hard. We need to correlate data from multiple index and various fields. We are trying painless script. Example: We make a search in an index to gather data about the…
0
votes
0 answers

How to get unanalyed text in ES for RegEx or WildCard queries?

With a text field, if I do a doc['my_text_field'] it shows analyzed tokens. As a result, the regex and wildcard queries can not be formulated in a resonable way... Although, the text is available when doing adding a scripted field via…
Muhammad Ali
  • 712
  • 7
  • 14
0
votes
0 answers

Check null parameter in painless - Elasticsearch

How are we supposed to check whether a key in map passed as parameter to a painless script has a value? I am currently doing this in Elasticsearch 6.8.4 if (params.feedId!=null) { whatever() } but it throws this exception when…
Fran García
  • 2,011
  • 16
  • 24
0
votes
1 answer

Loop through array from Elastic script Params

I'm creating a (ElasticSearch) Painless script. And as parameter I'm setting an array, but I'm not able to loop trough that array in my script. Elastic params setter (with NEST): Params = new Dictionary { …
BvdVen
  • 2,921
  • 23
  • 33
0
votes
2 answers

Elasticsearch "Painless" returns wrong and rounded values

Running Elasticsearch 7.3.2. I have two float fields "timeEnd" and timeStart. I simply want to return difference. In Kibana index-patterns I created a scripted variable "rate": if (doc['timeEnd'].length==0) return null; if…
0
votes
1 answer

ElasticSearch update API script - create array of structures

I am using Elasticsearch 6.5. I am writing a script for an update API in painless. I need to add structures to an array of structures. If this field does not exist in the document (I can detect that) I am creating a new array with the first…
Michał Herman
  • 3,437
  • 6
  • 29
  • 43
0
votes
1 answer

How to write a scripted field to get the number of days between status transition

I have two fields in an index named created_on and closed_on with date format July 15th 2019, 17:40:09.000, i want to write a painless scripted field to calculate the number of days between these two dates. I have tried this: def res_date= 0; def…
0
votes
1 answer

what exactly does painless do under the hood of painless script's Array contains method

Suppose that i have a doc mapping field like below { "template": { "mappings":{ "template":{ "properties": { "sth": { "type": "long" } …
user8510613
  • 1,242
  • 9
  • 27
0
votes
1 answer

elasticsearch with painless script to return extra fields

I am following this example https://www.compose.com/articles/how-to-script-painless-ly-in-elasticsearch/ where BOTH the ORIGINAL fields plus the calculated field (some_scores) are presented in the result document. { "_index": "sat", …
Mary Jane
  • 139
  • 3
  • 10
0
votes
1 answer

Sorting by product price considering special prices (client, group, country)

we have a shop with a few products (~ 5000). There are, of course, category overview sites which show all products that are in the current category. A requirement is that all products can be sorted by price (ASC and DESC). This already works…
user3180943
  • 181
  • 1
  • 2
  • 17
0
votes
1 answer

How to extract documents that has 2 or more nested object?

I am trying to extract documents that has 2 or more nested objects on Elasticsearch 6.1.2. our index has such a simple mapping. { "organizations": { "type": "nested", "properties": { "id": { …
Javvano
  • 969
  • 8
  • 16
0
votes
1 answer

java zoneddatetime: keep timezone ID when doing calculations

I have some small scripting-code in painless (a Groovy dialect, which itself is based on Java) that parses some timestamps with a zone-id. However, when doing calculations that involve crossing over a daylight-saving-time-boundary, the timezone-id…
Emil Bode
  • 1,784
  • 8
  • 16
0
votes
1 answer

How can I reject a value from json data type column in elasticsearch index result by using Painless?

My question is really simple and unique. I am trying get value from json string column in elasticsearch index. How can I get "ClassName" from below data? My rows is that: { "ClassName": "System.InvalidOperationException", "Message": "Sequence…
Penguen
  • 16,836
  • 42
  • 130
  • 205