I am trying to use script fields in my request. I included sandbox scripts and tried to use an expression to compute a new field.
The fact is that I get the following error:
{ "type": "expression_script_compilation_exception", "reason": "Only the member variable [value] or member methods may be accessed on a field when not accessing the field directly" }
It seems that only "value" is available. What am I missing here?
When executing the following query:
{ "query": { "match_all": {} }, "script_fields" : { "field1" : { "script" : { "lang": "expression", "inline": "doc['about.hobbies'].empty" } } } }
Matching:
{ "my_index": { "mappings": { "type": { "properties": { "about": { "properties": { "hobbies": { "type": "string", "analyzer": "lowercase" } } } } } } }
A little explanation: I have a field that can contain a list of string values.
"hobbies": ["a","b",c"]
and it may also be empty. I want to have a script field of type boolean that will be true if the list is not empty, and false when the list is empty.
Update : reading a few more, I meet this documentation on lucene expression scripts
There are several limitations to other script languages:
- Only numeric fields are available.
- Saved fields not available
- If the field is sparse (only some documents contain a value), documents that do not have a field will have a value of 0
My field is of type String, could that be the problem? If so, is there any other way to use script fields based on string fields? perhaps using groovy?
source share