# Lowercase Token Filter with preserve\_original

**URL:** <https://discuss.elastic.co/t/lowercase-token-filter-with-preserve-original/25999>\
**Category:** Elasticsearch\
**Created:** [July 21, 2015, 3:17pm UTC](https://discuss.elastic.co/t/lowercase-token-filter-with-preserve-original/25999 "2015-07-21T15:17:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zdeseb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zdeseb/32/42106_2.png) [@zdeseb](https://discuss.elastic.co/u/zdeseb)\
**Post date:** [July 21, 2015, 3:17pm UTC](https://discuss.elastic.co/t/lowercase-token-filter-with-preserve-original/25999/1 "2015-07-21T15:17:41Z")

</div>

**Is there any way how to apply lowercase token filter and preserve original tokens too?**

Our goal is to be able to search terms **case-insensitive** (by Span Term and lowercased text) **together with case-sensitive search** (by Span Term and correct text with appropriate upper case characters - useful for example for abbreviations, company names, etc.) **in the same** for example **Span Near Query**.

Thanks,  
Zdenek

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [July 21, 2015, 5:33pm UTC](https://discuss.elastic.co/t/lowercase-token-filter-with-preserve-original/25999/2 "2015-07-21T17:33:46Z")

</div>

The lowercase filter does not allow to do that. Besides such a approach would raise issues with term statistics. There is no other way to do what you want right now, but maybe it would be in the future if you indexed two fields (with a multi-fields) and then used Lucene's [FieldMaskingSpanQuery](http://lucene.apache.org/core/5_0_0/core/org/apache/lucene/search/spans/FieldMaskingSpanQuery.html) to be able to build a SpanNearQuery across two fields. For it to work, we would need to expose FieldMaskingSpanQuery in elasticsearch first.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 23, 2015, 6:59am UTC](https://discuss.elastic.co/t/lowercase-token-filter-with-preserve-original/25999/3 "2015-07-23T06:59:03Z")

</div>

You could leverage multifields though?

---

<div class="post-metadata">

**Author:** ![zdeseb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zdeseb/32/42106_2.png) [@zdeseb](https://discuss.elastic.co/u/zdeseb)\
**Post date:** [July 23, 2015, 10:44am UTC](https://discuss.elastic.co/t/lowercase-token-filter-with-preserve-original/25999/4 "2015-07-23T10:44:38Z")

</div>

Multifields cannot be used in our use-case because it is not possible to combine different multifields in one Span Query (that's what FieldMaskingSpanQuery will solve as Adrien wrote above).

---

<div class="post-metadata">

**Author:** ![zdeseb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zdeseb/32/42106_2.png) [@zdeseb](https://discuss.elastic.co/u/zdeseb)\
**Post date:** [July 23, 2015, 10:45am UTC](https://discuss.elastic.co/t/lowercase-token-filter-with-preserve-original/25999/5 "2015-07-23T10:45:30Z")

</div>

Thanks for answer

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:59pm UTC](https://discuss.elastic.co/t/lowercase-token-filter-with-preserve-original/25999/6 "2017-07-05T23:59:34Z")

</div>


