hello to everyone,
i want to know how to create a screpted fields. the field is a string and I have to check if it starts with edi. if so the value of the field e EDI else "-".
how can I do. I need some help because I'm completely blocked.
thank you so much
indexOf is a method of the string variable type that takes a substring (edi) and returns back a number for the index of where that substring begins.
So if the string actually starts with edi, then the index of that substring will be 0, because the index value is 0-based. If the string doesn't contain that substring at all, then indexOf will return a -1.
When we find that the index of the substring is 0, then we return a value that becomes the value for the scripted field (EDI). If anything else happens, we return a null.
Painless is based on Groovy and is pretty much a subset of it. It restricts usage of the insecure methods and libraries, but usually you can refer to Groovy documentation to figure out how to do something:
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.