Convert . to dot

can opensearch do this?
:If my docs have . in it like, it should index it as abcdotcom. and similarly if it has mon & tues, it should index it as mon and tues

if so, how could I accomplish this?

If you want the data to live that way in the index then you would have to adjust the pipeline that is ingesting the data into your cluster with data-prepper, logstash or the like. I am not sure if there is a way to do this with scripted fields and such. As with any data store, it’s usually easier to normalize your data before it is saved in the data store.

You can also do this in analysis. If you have the standard analyzer (default), then you can have a custom analyzer using:

1 Like

Thanks! the char_filter is exactly what I want. Is there a possibility to add a filter, meaning apply the char_filter (convert . to dot) only if the term has @ in it. (Ideally I want only the . in email IDs to be converted as dot. Would you happen to have an example for this? → regex + char_filter

I think it’s possible, though I don’t know the exact regex. But you can use captures to identify the bits of the Email address that you want to keep and put them in the replacement.

For example, if the string is, a regex like this should match (didn’t test it with OpenSearch, though):

"pattern": "(\\w+)@(\\w+)\\.(\\w+)"

And then in the replacement (again, untested):

"replacement": "$1@$2dot$3"

In short, the functionality is there, it’s a matter of mastering regexes :slight_smile: