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

Elasticsearch search query: why params._source.nested_field.size() is not working in script?

There are lot of questions and answers about this but still didn't get a satisfied answers. Elasticsearch version: 6.5 Index mapping "_doc": { "properties": { "ssid": { "type": "long" }, "nested_field": { …
Avi
  • 434
  • 6
  • 20
5
votes
1 answer

Convert IP (string) into long in elasticsearch/kibana scripted fields

I have a field in a doc that is a string representation of ipv4 ("1.2.3.4"), the name of the field is "originating_ip". I'm trying to use the scripted fields using the painless language in order to add a new field (originating_ip_calc) to have the…
Dekel
  • 60,707
  • 10
  • 101
  • 129
5
votes
0 answers

Elasticsearch scripting Engine Implementation for groovy tf queries

Currently, on ES 5.6, we are using groovy inline scripting to get tf of a given term in a field for given documents like - GET document/_search { "size": 114, "query": {"terms": { "doc_id": [1840, 2160] }}, "script_fields": { …
5
votes
2 answers

Painless (Elasticsearch) convert any type of value to integer

I am converting an Elasticsearch script from Groovy to Painless. The script accepts a parameter, which can be either an integer or a string convertible to an integer (i.e. could be either 123 or "123"). In Groovy, doing my_val.toLong() converted…
pmishev
  • 896
  • 9
  • 22
5
votes
0 answers

Painless scripting Elastic Search : variable is not defined error when trying to access values from doc

I am trying to learn painless scripting in Elastic Search by following the official documentation. ( https://www.elastic.co/guide/en/elasticsearch/painless/6.0/painless-examples.html ) A sample of the document I am working with : { "uid" :…
4
votes
1 answer

ElasticSearch Accessing Nested Documents in Script - Null Pointer Exception

Gist: Trying to write a custom filter on nested documents using painless. Want to write error checks when there are no nested documents to surpass null_pointer_exception I have a mapping as such (simplified and obfuscated) { "video_entry" : { …
4
votes
1 answer

trying to pass params to elasticsearch getting null_pointer_exception

I'm trying to send to Elasticsearch the following query. Here is the most minimal update by query which gives me the exception. Lets name it Query1: { "id": "someID", "script": { "lang": "painless", "source": " if…
qballer
  • 2,033
  • 2
  • 22
  • 40
4
votes
1 answer

To console/check value in painless script

Do we have any option to print/console the variables value in painless script? To get it view in the simulated result.
Dinesh
  • 189
  • 1
  • 7
4
votes
1 answer

how to update by query to create incrementing ranking from sorted query in elasticsearch 6.4

I'm trying to _update_by_query in order to rank items in a sorted search. Is it possible to get the current "index" of the document in the script? eg. create index: PUT test { "mappings" : { "person" : { "properties" : { …
4
votes
1 answer

Translate Elastic Search numeric field to a text value

I have an Elastic Search cluster with a lot of nice data, that I have created some nice Kibana dashboards for. For the next level I decided to take a look at scripted fields to make some of the dashboards even nicer. I want to translate some of…
Jay Pete
  • 4,123
  • 4
  • 35
  • 51
4
votes
0 answers

ElasticSearch: Query syntax is painful

I just have started working on ElasticSearch and it is painful to write in Painless. So difficult to see the connections between brackets, too many spaces. I am working on the outlier detection and as an example, this is what the code looks like:…
Doren
  • 139
  • 1
  • 6
4
votes
1 answer

Elasticsearch: Scripted Metric Aggregation returns weird grouping

I'm getting an unexpected result and I'm a bit lost. I added these docs: POST es_test/_doc/_bulk?pretty { "index": {}} { "firstname": "John", "lastname": "Doe", "age": 22, "birthdate": "1980-01-20T12:30:00Z" } { "index": {}} { "firstname": "May",…
4
votes
0 answers

Is it possible to order split series in Kibana histograms using the values of the split buckets?

Say I have an index of product sales where each document is an individual sale for a specific product. I can use Kibana to chart a date histogram of sales counts, bucketing by every month. This would be the frequency of product sales every month.…
4
votes
0 answers

Elasticsearch painless query exception

I am using Elasticsearch 6.2 which uses painless for the inline scripting. One of the fields in my doc has mapping: "gap_days": {"type": "integer"} And I have a painless script for search and the few lines are: int gap = 10; //initialize to a…
4
votes
1 answer

How do you use min/max in ElasticSearch inline scripts?

Learning some elasticsearch here and I'm a bit stumped on using min and max functions in scripted field definitions. First, GET my_index/_search { "query" : { "match_all": {} }, "script_fields" : { "test1" : { …
rschwieb
  • 746
  • 2
  • 16
  • 41
1
2
3
32 33