Pattern Matching in Elasticsearch

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 ?


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.

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