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

How to find records matching the result of a previous search using ElasticSearch Painless scripting

I have the index I attached below. Each doc in the index holds the name and height of Alice or Bob and the age at which the height was measured. Measurements taken at the age of 10 are flagged as "baseline_height_at_age_10": true I need to do the…
RaamEE
  • 3,017
  • 4
  • 33
  • 53
0
votes
1 answer

Calculate two date duration in Elastic 6.7 using painless script

I used below simple expression for getting duration: doc['endTime'].date.millisOfDay - doc['startTime'].date.millisOfDay But the problem starts when, endTime crosses the startTime day. Example: If startTime is 23:50 and endTime for the same is…
Indrajeet Gour
  • 4,020
  • 5
  • 43
  • 70
0
votes
1 answer

Number of specific elements in a nested list

An Elastic document has a structure like this: ... "somefield": "somevalue", "orders": [{ "version": 1, "statusCode": 1 }, { "version": 1, "statusCode": 1 }, { "version": 2, "statusCode": 2 …
FireShock
  • 1,082
  • 1
  • 15
  • 25
0
votes
1 answer

How to add multiline painless code in nodejs

So in my js-code I have this line: var _script = { _script: { script: { lang: 'painless', source: ` """ …
oderfla
  • 1,695
  • 4
  • 24
  • 49
0
votes
1 answer

How to use script upsert in logstash for updating document

I am using below output block to upsert the document and incrementing the counter (partial updates) for an existing document with matching ID. Currently, post first doc entry into elasticsearch , "script" has not impact through the subsequent update…
0
votes
0 answers

Undefined variable in painless script

I have a document that has this structure (pseudo code, just to understand the structure in json): source{ id, property: {prop1, prop2} } I am in need of sorting the result of a search either by prop1 or prop2. I also have an array (hard…
oderfla
  • 1,695
  • 4
  • 24
  • 49
0
votes
1 answer

java: get one parameter from url

How can I get one specific uri parameter from an URL? For example my url /search?q=foo&oq=bar&aqs=chrome&client=android&sourceid=chrome-mobile&ie=UTF-8 Now I want only return the q parameter (foo). My solution was to try it with a substring till…
jonny
  • 9
  • 6
0
votes
1 answer

Reverse a string in KIBANA/painless

I'm not able to reverse a string in KIBANA/painless (section: scripted fields) def foo = ('dlroW olleH'); return foo.reverse(); I expect the output of "Hello World", but KIBANA sais "No results found". If i do a "return foo;" it works well - on…
stsm
  • 43
  • 5
0
votes
1 answer

Elasticsearch: efficient sorting on nested values

I am sorting results from Elasticsearch (5.1.1) based on a calculation of values in nested key/value structures. The sorting has to: find values from given keys across multiple nested structures multiply those values with one another use this…
Scarabas
  • 103
  • 1
  • 1
  • 7
0
votes
1 answer

Combine nested fields in scripted field

I would like to create a scripted field that checks two properties of a nested field. I have an ES index that contains information about processes. A process is configured as a nested object. Each doc can have more than one process. It is also…
NeleR
  • 43
  • 5
0
votes
1 answer

Get result from aggs in script ElasticSearch/Painless

I'm new in ElasticSearch world. I've been trying write simple request and I need to get aggs result in my script to make simple condition. Is it possible to do it in this way? The condition below is only for example. GET _search { "aggs" : { …
XtrEmE
  • 13
  • 6
0
votes
2 answers

How to compare hours on elasticsearch

I am trying to compare hours using painless language in my elasticsearch query. I would like query something like: { "script":"doc['schedule.from_time'] >= doc['schedule.to_time']" } But I have the error: Cannot apply [>] operation to types…
Jérémy
  • 111
  • 6
0
votes
1 answer

Elastic Search Painless Script Document

I am new to ES, and I am trying to write a search query with aggregations. While writing the same, I am facing issues with the Painless script. Where can I get the complete painless script document, which is used in Elastic Search?
0
votes
0 answers

Elasticsearch 6.4 scripted_metric aggregation Bad performance against ElasticSearch 5.1

I have 2 clusters of ElasticSearch: old 3 nodes(master+data) ElasticSearch: 5.1.2 java : openjdk version "1.8.0_111" -Xms12g -Xmx12g new 6 nodes(3 master + 3 data) with much better hardware (cpu/ram/hdd) ElasticSearch: 6.4 java : openjdk…
0
votes
1 answer

With ElasticSearch sort by given array

I'm storing in ElasticRearch a series of feeds. Each feed is has the actor posting such feed and the posting date. In another place I store a weighted value for each actor in this way: weights: [{'id': 'mark', 'weight': 1}, {'id': 'jane', 'weight':…
QLands
  • 2,424
  • 5
  • 30
  • 50