radi
(radi)
January 8, 2018, 2:35pm
1
Hell i have this script with collection it's working in groovy But I can't find if there's a way to do this with painless ?
GET exemple/_search
{
"script_fields" : {
"checks" : {
"script" : {
"lang": "groovy",
"inline":
"_source.mebers.collect{it.check}"
}
}
}
}
weltenwort
(Felix Stürmer)
January 8, 2018, 3:35pm
2
Hi @radi ,
the collect
method still exists on collections, but the lambda function syntax is similar to the java sytax, i.e.
GET example/_search
{
"script_fields": {
"checks": {
"script": {
"lang": "painless",
"source": "doc['members'].collect(member -> member.check)"
}
}
}
}
radi
(radi)
January 8, 2018, 3:45pm
3
thenk's for your replay ,
I tested this solution but I have this error
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "[script] unknown field [source], parser not found"
}
],
"type": "illegal_argument_exception",
"reason": "[script] unknown field [source], parser not found"
},
"status": 400
}
weltenwort
(Felix Stürmer)
January 8, 2018, 4:29pm
4
Which version of the Elastic Stack are you running?
radi
(radi)
January 8, 2018, 4:36pm
5
Elastic Stack version 5.4.0
weltenwort
(Felix Stürmer)
January 8, 2018, 4:39pm
6
In that version the key is still called inline
, so this should work:
GET example/_search
{
"script_fields": {
"checks": {
"script": {
"lang": "painless",
"inline": "doc['members'].collect(member -> member.check)"
}
}
}
}
radi
(radi)
January 8, 2018, 4:47pm
7
already test , and i have this error
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "invalid sequence of tokens near ['->'].",
I need to use _source ( like in groovy )
but i read this now !
[https://github.com/elastic/elasticsearch/issues/20068 ](http://painless _source )
_source is definitely a controversial issue, but as of right now, _source is only supported in update scripts within Painless.
weltenwort
(Felix Stürmer)
January 8, 2018, 4:55pm
8
hm, this works for me in Kibana 5.4.3:
GET example/_search
{
"script_fields": {
"checks": {
"script": {
"lang": "painless",
"inline": "params._source['members'].collect(member -> member.check)"
}
}
}
}
system
(system)
Closed
February 5, 2018, 5:01pm
10
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.