# Pattern Matching in Elasticsearch

**URL:** <https://discuss.elastic.co/t/pattern-matching-in-elasticsearch/142338>\
**Category:** Elasticsearch\
**Created:** [July 31, 2018, 10:24am UTC](https://discuss.elastic.co/t/pattern-matching-in-elasticsearch/142338 "2018-07-31T10:24:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eth](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eth/32/120441_2.png) [@eth](https://discuss.elastic.co/u/eth)\
**Post date:** [July 31, 2018, 10:24am UTC](https://discuss.elastic.co/t/pattern-matching-in-elasticsearch/142338/1 "2018-07-31T10:24:16Z")

</div>

Hi  
I want to create a mapping for an index which has a field named "interval". The "interval" field should allow only certain values, such as 1M,1d or 1H. How do we achieve this ? Is this possible through pattern matching during static mapping creation ? if not what are the other possibilities ?

Thanks  
eth

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 31, 2018, 10:41am UTC](https://discuss.elastic.co/t/pattern-matching-in-elasticsearch/142338/2 "2018-07-31T10:41:46Z")

</div>

I don't think there is anything like that. I'd recommend using a common base like the smallest unit you can use and convert to that size.

For example if hour is the smallest unit then convert on your side 1H to 1, 1d to 24, ...

Note that you have the `date-range` datatype though that might help you if needed.

---

<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:** [August 28, 2018, 10:41am UTC](https://discuss.elastic.co/t/pattern-matching-in-elasticsearch/142338/3 "2018-08-28T10:41:49Z")

</div>

Closed on August 28, 2018, 10:41am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
