Replace diacritic (accented) characters
Managed by | Updated .
The following post process hook script takes a metadata field containing diacritic characters and produces a second normalised field with the accented characters replaced with non-accented versions.
Useful if you need to strip the characters - eg. on query completion triggers that might need to match the diacritics.
hook_post_process.groovy
import java.text.Normalizer;
import java.text.Normalizer.Form;
transaction?.response?.resultPacket?.results.each() {
// Created a normalised version of the name metadatafield that removes diacritics
it.metaData["nameNormalized"] = Normalizer.normalize(it.metaData["name"], Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
}
Was this artcle helpful?
Similar
- Adding numeric metadata constraints via a hook script
- Modifying the highlight regular expression used by <@s.Boldicize>
- Set non CGI query processor options in hook script
- Writing hook script code for specific search types
- Disable extra searches via a hook script
- Removing input parameters for extra searches
Latest In this section
- Replace diacritic (accented) characters
- Accessing data model variables that start with a single lower case letter
- Adding numeric metadata constraints via a hook script
- Modifying geo-spatial parameters in the data model (origin, maxdist)
- Storing custom data within the data model
- Writing hook script code for specific search types