# How to replace multiple spaces for the field value before creating the document using pattern analyzers

**URL:** <https://discuss.elastic.co/t/how-to-replace-multiple-spaces-for-the-field-value-before-creating-the-document-using-pattern-analyzers/360658>\
**Category:** Elastic Search\
**Created:** [June 1, 2024, 11:43am UTC](https://discuss.elastic.co/t/how-to-replace-multiple-spaces-for-the-field-value-before-creating-the-document-using-pattern-analyzers/360658 "2024-06-01T11:43:33Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Artem\_Shelkovnikov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/artem_shelkovnikov/32/134322_2.png) [@Artem\_Shelkovnikov](https://discuss.elastic.co/u/Artem_Shelkovnikov)\
**Post date:** [June 3, 2024, 9:22am UTC](https://discuss.elastic.co/t/how-to-replace-multiple-spaces-for-the-field-value-before-creating-the-document-using-pattern-analyzers/360658/2 "2024-06-03T09:22:58Z")

</div>

Do you have control over the code that you use to ingest the data into Elasticsearch? If so, it's probably better to do normalization/trimming before ingesting data.

Additionally - have you seen this post: [Keyword analyzer but allow redundant white spaces](https://discuss.elastic.co/t/keyword-analyzer-but-allow-redundant-white-spaces/110441)?

---

_[View the full topic](https://discuss.elastic.co/t/how-to-replace-multiple-spaces-for-the-field-value-before-creating-the-document-using-pattern-analyzers/360658)._
