You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
String fieldValue = ctx['redacted'];
Pattern pattern_ssn = /(\d{3}-?\d{2}-?\d{4})/;
Pattern pattern_phone = /(\d{3}?-?\d{3}-?\d{4})/;
List patterns = new ArrayList();
patterns.add(pattern_ssn);
patterns.add(pattern_phone);
for (p in patterns) {
Matcher matcher = p.matcher(ctx['redacted']);
ctx['redacted'] = matcher.replaceAll("<redacted>");
}
Test
Input doc for ingest pipeline
[
{
"_source": {
"message": "Hello, my name is Bruce Wayne and I live in Gotham. My SSN is 123-45-6789 and you can reach me at 312-456-7890"
}
}
]
Example Output
{
"doc": {
"_index": "_index",
"_id": "_id",
"_version": "-3",
"_source": {
"redacted": "Hello, my name is <PER> and I live in <LOC>. My SSN is <redacted> and you can reach me at <redacted>"
},
"_ingest": {
"timestamp": "2023-01-19T15:26:45.161817903Z"
}
}
}