hello to everyone!
I am trying to create a scripted field that will return some specific values from a field.
This field contains a long string and I want to take some specific values which is the some_text_here
. The values are inside<></>
such as <textA>some_text_here</textA>
Please look below the content of the specific field from where I want to extract some substrings:
....<textA>some_text_here </textA> <language>español</language> <textA>some_text_here</textA><textA>some_text_here</textA>....
eg ....<textA>I am </textA> <language>English</language> <textA>very</textA><textA>happy</textA>....
Please look the below code from my scripted field:
if (doc['content.keyword'].size()!=0) {
def string = doc['content.keyword'].value;
if (string != null) {
def m = /textA(.*)textA/.matcher(string);
if (m.find()) {
return m.group(1);
}
return "no match";
}
return "empty";
}
With this scripted field, I can extract only the value from the first <textA> </textA>
(eg I am
from the example).
Have you any idea how to get also the rest some_text_here
values simultaneously in order to have the three some_text_here
together.
The output value would be something like this:
some_text_here some_text_here some_text_here
eg I am very happy
from the example.
I searched a lot here in the community but I cannot write something that working.
Thank you in advance for any help!!!