Replace bad words in a field and save result back to field without indexing the field

129 views Asked by At

I have a "bio" field in User documents and I don't want to index the "bio" field but at the same time I would like to replace bad words in the "bio" field with "****", then save the edited "bio" so that bad words will not show when a User document is returned in a search result.

Is this doable. I am new to ElasticSearch and would appreciate any help. I am using version 6.8. Thanks

1

There are 1 answers

0
Srikanta On

A field within a doc can only be manipulated before it is indexed or doc as a whole is persisted within Elasticsearch.

So you would need to use a tool such as Logstash with "KV filter" to replace words with asterisk symbols https://www.elastic.co/guide/en/logstash/current/plugins-filters-kv.html

When done this way, the documents when returned as part of the search will have the fields redacted as per the Key list mentioned in the Logstash.