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
1 answer
Aggregations with dynamic data / nested_objects
I'm trying to aggregate over dynamically mapped fields in ElasticSearch.
For example:
POST test/_doc/1
{
"settings": {
"range": {
"value": 200,
"display": "200 km"
},
"transmitter": {
…

Patrick
- 7,903
- 11
- 52
- 87
1
vote
0 answers
How to create a slow query?
Elasticsearch v7.7.1
How can I create a slow query? It is for a test purpose.
For now, I tried to brute force a prime number check:
GET _search
{
"script_fields": {
"AvgTicketPrice": {
"script": {
"lang": "painless",
…

srgbnd
- 5,404
- 9
- 44
- 80
1
vote
0 answers
Can aggregated buckets from composite aggregation be merged or grouped by a field?
Can aggregated buckets from composite aggregation be merged?
Sample bucket from composite aggregation:
{
{"unique_app_id": "app_0001", "app_title": "calendar v1"}
{"unique_app_id": "app_0001", "app_title": "calendar v2"}
{"unique_app_id":…

RNA
- 1,164
- 2
- 19
- 35
1
vote
1 answer
How to create a HashMap with custom object as a key?
In Elasticsearch, I have an object that contains an array of objects. Each object in the array have type, id, updateTime, value fields.
My input parameter is an array that contains objects of the same type but different values and update times. Id…

wst
- 4,040
- 4
- 41
- 59
1
vote
1 answer
Average aggregation on date datatype in Elasticsearch?
I have stored the 3 date datatype variable (date1, date2, date3) in my index using a stored script. I have calculated duration between two date variables(date2 - date1) and stored in the third date variable (date3). Here is my complete mapping,…

hsraps
- 31
- 4
1
vote
1 answer
How to access the date_histogram key field in the child aggregation in elasticsearch?
I want to apply some filters on the bucket response generated by the date_histogram, that filter is dependent on the key of the date_histogram output buckets.
Suppose I have following data in
{
"entryTime":"",
"soldTime:""
}
the elastic…

Viral Shah
- 13
- 3
1
vote
1 answer
elasticsearch aggregate array of strings
I need an aggregation query to get a bucket with all my root folders. All documents in my elasticsearch have a field named path where I store an array with the paths where the document is located ( e.g. path=[1.3., 1.2.4, 5., 11] ).
If I use the…

MOE
- 769
- 6
- 19
1
vote
0 answers
null_pointer_exception in percolator query matching against stored scripts
I am using Elasticsearch version 6.8.
I have some percolator queries containing stored scripts which matches a regular expression against some fields. Scripts are like below:
{
"_id" : "05441b99218d27e831414b4584ef628e",
"found" : true,
…

Puja Agarwal
- 11
- 2
1
vote
1 answer
How to instantiate object in painles script of ElasticSearch
In Java I have entity with nested objects:
public class MyData {
@Id
public UUID id;
@Field(type = FieldType.Nested)
public List entries = new ArrayList<>(); // Entry is the class with two fields: String and int
}
I want to…

user2220154
- 47
- 8
1
vote
0 answers
Having trouble getting results with painless script
Here is my aggregation:
"aggregations": {
"nested-econtext": {
"nested": {
"path": "econtext"
},
"aggregations": {
"nested-name": {
"terms": {
"field": "econtext.name.raw",
"size": 2147483647,
…

Chieve
- 59
- 6
1
vote
1 answer
Need an elasticsearch query filter range which starts 5 minutes before scheduled time
I'm using elasticsearch 6.5.4, and a kibana watcher to alert.
I have a filter range like so:
"filter": [
{
"range": {
"@timestamp": {
"gte": "{{ctx.trigger.scheduled_time}}||-{{ctx.metadata.triggered_interval}}m"
}
}
…

fbat
- 27
- 9
1
vote
0 answers
_update_by_query fails to update all documents in ElasticSearch
I have over 30 million documents in Elasticsearch (version - 6.3.3), I am trying to add new field to all existing documents and setting the value to 0.
For example: I want to add start field which does not exists previously in Twitter document, and…

aniketk
- 109
- 1
- 7
1
vote
0 answers
Elasticsearch document sorting based on nested values
I have the following data indexed in my elasticsearch version 7.4.
[
{
"users": [
{
"age": "31",
"dept": "IT",
"city": "Chennai"
},
{
"age": "25",
"dept": "Accounts",
"city":…

Gowtham Raj
- 103
- 2
- 13
1
vote
1 answer
ElasticSearch 6.7 painless, how to access nested document
When I use ES 5.5 update to 6.7.
Painless script does’t work
This is 5.5
If I want get a nested document [transFilter]
I do this
params['_source’]['carFilter’]
It works very well。
But
When I used 6.7 version
params['_source’]['carFilter’]
I…

brooks
- 11
- 4
1
vote
1 answer
Loop through items with painless but 'No field found'
I'm trying to make a select query with a Painless script, but I keep getting an error in the response that the script is not valid.
What I'm trying to do in this simplified script is to check if my given param ages are both adult following the age…

BvdVen
- 2,921
- 23
- 33