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

Elasticsearch partial update of Object(multi=True)

How to update document with field mapping Object(multi=True), when a document can have both single (dictionary) and multiple values (list of dictionaries). Example of documents in the same index: A single value in items: { "title": "Some…
wowkin2
  • 5,895
  • 5
  • 23
  • 66
1
vote
1 answer

elastic search: how to terminate a multi search query once we get desired result

We have elastic search document with a string field named "Type". This field can have different values from "A" to "Z". Multiple documents can have the same type i.e. multiple documents can have Type "A" We want to write an elastic search query that…
Sahil Sharma
  • 3,847
  • 6
  • 48
  • 98
1
vote
0 answers

Generate sequence for Elasticsearch response

How can I generate a sequence for every document returned in a Elasticsearch query (first hit a 1, second hit a 2 and so on). Regards
flopeko
  • 149
  • 8
1
vote
1 answer

How does elasticsearch handle returns inside a scripted update query?

I can't find the relevant documentation describing the return keyword. Where is this documented? I am running the following query POST /myindex/mytype/FwOaGmQBdhLB1nuQhK1Q/_update { "script": { "source": """ if…
Simon
  • 1,681
  • 1
  • 21
  • 34
1
vote
2 answers

Elasticsearch 6.2 - how to format date (epoch) field in yyyymm string in painless inline scripting

In Elasticsearch 6.2, I have an index where there are two timestamp fields as follows: "start_ts": { "type": "date", "format": "epoch_second" }, "end_ts": { "type": "date", "format": "epoch_second" } In my painless…
JVK
  • 3,782
  • 8
  • 43
  • 67
1
vote
0 answers

Is it possible to delete another document in painless script in Elasticsearch?

I need to create a function to merge documents. I know how to update a document for merging but I don't want to send another request for deleting document being merged. In Painless script, is it possible to find and delete another document by query…
tom10271
  • 4,222
  • 5
  • 33
  • 62
1
vote
0 answers

Runtime Error on Split in Keyworded Field

This is an example of a mapping we have in ES: mapping = { 'settings': { 'number_of_shards': 1, 'number_of_replicas': 0, }, 'mappings': { '_doc': { 'properties': { 'cat': { …
Willian Fuks
  • 11,259
  • 10
  • 50
  • 74
1
vote
1 answer

Elasticsearch scripted query painless exponential function

With Elasticsearch and painless is there a way to implement an exponential function? I can't seem to find anything. I have something like this. bdy = { "from" : 0, "size" : 10, "query": { "function_score": { "query":…
Glen Thompson
  • 9,071
  • 4
  • 54
  • 50
1
vote
1 answer

Painless script to retrieve latest date in nested structure

I'm trying to modify this painless script so I can retrieve the MAX date from the nested structure. Pretend I have mapping like so: { "mappings": { "hello": { "properties": { "field1": {"type" : "date",…
Ed Baker
  • 643
  • 1
  • 6
  • 16
1
vote
1 answer

ElasticSearch rounds float value in painless script

I noticed rounding issue when using scripting feature of ElasticSearch. I've the following mapping: { "my-index": { "mappings": { "my-document": { "properties": { "id": { "type": "long" }, …
raduy
  • 482
  • 5
  • 11
1
vote
1 answer

" version conflict, current version is different than the one provided" when running update_by_query curl in php script

I have to update some fields in my ES documents. I have an interger 'objectID' field, which is an unique id of the object concerned by the document. I have a String 'objectType' field, which is the type of object concerned by the document. All…
littledaxter
  • 121
  • 1
  • 8
1
vote
1 answer

Elasticsearch sorting buckets of dates with script

I have an interesting sorting problem with Elasticsearch. I have the following data: Item => A B C D E F Time => -3 -2 -1 0 1 2 3 The above graphic shows that I have 6 pieces of data, items A-F, and…
Jordan Ell
  • 1,745
  • 3
  • 16
  • 24
1
vote
1 answer

MySql Order By Value equivalent in ElasticSearch 5.6

ElasticSearch Version: 5.6 I have imported MySQL data in ElasticSearch and I have added mapping to the elastic search as required. Following is one mapping for the column application_status. Mappings: { "settings": { "analysis": { …
Sagar Chilukuri
  • 1,430
  • 2
  • 17
  • 29
1
vote
1 answer

How to apply mathematical operation on elastic search aggregations bucket data

I am using elastic search 5.5.1. My requirement is to apply following formula : (doc_count*100/10) on below set of data : { "took": 30, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { …
Nitish Raj
  • 137
  • 1
  • 2
  • 12
1
vote
1 answer

Painless Script - Cast String to def

I'm trying to get number of a string. I'm doing this using a regex pattern. When I get the result, i get something like "1", "10", "2". I want to sort it, so I need to add zero to the left in order to sort them naturally. My script is here: { …
NatsuDragonEye
  • 109
  • 5
  • 18