Reputation: 23277
I'm performing this groovy script in my elasticsearch instance. This is the content of a groovy script located in /usr/share/elasticsearch/config/scripts
:
def opDate = new DateTime(doc['" + field + "'].date);opDate.getYear();
It's reached and ES is trying to perform it, nevertheless it's telling me:
No field found for [" + field + "] in mapping with types [fuas]
This is the Java code I send to ES:
AggregationBuilders
.terms(this.getName())
.field(this.getName())
.script(
new Script(
"year",
ScriptType.FILE,
"groovy",
ImmutableMap.of("field", this.getName())
)
);
Upvotes: 0
Views: 1015
Reputation: 217554
You have a few too many quotes in there. Modify your script like this (field
is a parameter to your script):
def opDate = new DateTime(doc[field].date);opDate.getYear();
Upvotes: 1