-1
Hello, folks are in need of a help with Elasticsearch. I’m trying to do a script conversion, from a string field, to double, but unfortunately, I’m not getting it. the last script I did was this:
def cod=0; if(String.valueOf(doc['codProduto.keyword'].value)!=null){ String sCod = doc['codProduto.keyword'].value; cod = Double.parseDouble(sCod);} return cod;
but returns this error
"caused_by" : { "type" means "illegal_state_exception", "Reason" : "A Document doesn’t have a value for a field! Use doc[]. size()==0 to check if a Document is Missing a field!"
but if I do the script that way:
def cod=0; if(doc['codProduto'].size()>=0){ String sCod = doc['codProduto.keyword'].value; cod = Double.parseDouble(sCod);} return cod;
returns this error: ** "Text Fields are not Optimised for Operations that require per-Document field data like aggregations and Sorting, so These Operations are disabled by default. Please use a keyword field Instead. Alternatively, set fielddata=true on [codProduct] in order to load field data by uninverting the Inverted index. Note that this can use significant memory." **