We created a simple string script field, and we are getting a error in discovery and when we try to use that script field in any vizualization.
I belive the images will explain it better:
The script field:
Are there any null values for osInfo.raw in your entire DB?
Also the error you posted has if(name.contains..... but I don't see that in the scripted field. Looks like the scripted field it's trying to run is more than just the one line I see in the other image.
Ok, going to try that. I think thats probaly it, I tested in discovery and vizualize again, but with results from the last 15 minutes and from the last 24 hours, and it worked with no problems, but when I put to get values from the last 7 days, the exact error appears again. I don't really know if a .IsNull() method works in the script, so I'm going to search the best way to deal with nulls.
I guess it was the null values. Tryed to solve by adding a conditional in the start: if(doc['osInfo.raw'].value == null) { return " "; } else { name = doc['osInfo.raw'].value }
And after that I put the logic, a simple one: if(name.contains("Windows 10")) { return "Windows 10"; } else if (name.contains("Windows 7")) { return "Windows 7"; } return " ";
But it didn't solved it!, it worked when I added a filter directly in the vizualize and discovery: osInfo.raw: exists
Thanks for the help!!!!!!
Having to put the filter to avoid errors have some limitations when you try to use filters with the script field, because it only works with the osinfo.raw: exists filter, and it removes from the query some lines that don't have this information, but would be usefull. Is there a right or specific way to filter null values? I tryied using isNull() inside an if,to put a black value in case isnull() was true, but it didn't work.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.