# How to filter a field with entries of different version number formats in Elasticsearch documents

**URL:** <https://discuss.elastic.co/t/how-to-filter-a-field-with-entries-of-different-version-number-formats-in-elasticsearch-documents/245427>\
**Category:** Elasticsearch\
**Created:** [August 18, 2020, 1:24pm UTC](https://discuss.elastic.co/t/how-to-filter-a-field-with-entries-of-different-version-number-formats-in-elasticsearch-documents/245427 "2020-08-18T13:24:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![siiman](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@siiman](https://discuss.elastic.co/u/siiman)\
**Post date:** [August 18, 2020, 1:24pm UTC](https://discuss.elastic.co/t/how-to-filter-a-field-with-entries-of-different-version-number-formats-in-elasticsearch-documents/245427/1 "2020-08-18T13:24:02Z")

</div>

Hello, everyone,

how to filter and sort a field with entries of different version numbers in Elasticsearch documents?  
For example different documents contain the field `version` with entries like "10.0", "10.1.5", "9" or "23.932.01".

How can a "greater than" search be done by entering a version number. By default Elasticsearch saves the data as string. Simple conversion to a number is not possible due to the different formats.  
Is there a similar data structure as the data type `ip` to represent version numbers?

Always happy to hear from the community

---

<div class="post-metadata">

**Author:** ![dominique.bejean](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@dominique.bejean](https://discuss.elastic.co/u/dominique.bejean)\
**Post date:** [August 18, 2020, 9:13pm UTC](https://discuss.elastic.co/t/how-to-filter-a-field-with-entries-of-different-version-number-formats-in-elasticsearch-documents/245427/2 "2020-08-18T21:13:08Z")

</div>

Hi,

May be you can use pipeline with a script processor in order to build a new string field with

010.000.000.000  
010.001.005.000  
009.000.000.000  
023.932.001.000

Regards

Dominique

---

<div class="post-metadata">

**Author:** ![siiman](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@siiman](https://discuss.elastic.co/u/siiman)\
**Post date:** [August 19, 2020, 9:12am UTC](https://discuss.elastic.co/t/how-to-filter-a-field-with-entries-of-different-version-number-formats-in-elasticsearch-documents/245427/3 "2020-08-19T09:12:14Z")

</div>

Hi Dominique,

thanks for your answer. Unfortunately I didn't find a way to narrow down the search in Elasticsearch by using the `DSL` syntax and a `range filter`. (The Range filter does not work with string fields.)

Or do you think I should use the datatype `ip` here? Unfortunately I am limited in the formatting of the version numbers again.

kind regards  
Siiman

---

<div class="post-metadata">

**Author:** ![dominique.bejean](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@dominique.bejean](https://discuss.elastic.co/u/dominique.bejean)\
**Post date:** [August 19, 2020, 10:28am UTC](https://discuss.elastic.co/t/how-to-filter-a-field-with-entries-of-different-version-number-formats-in-elasticsearch-documents/245427/4 "2020-08-19T10:28:23Z")

</div>

Siiman,

A data can be indexed in several ways at the same time by using copy\_to and appropriate data type and analyse. For instance as a string for sorting and filtering and as text in order to tokenized. You can also imagine split the field in 4 distinct numeric or keyword fields.

Dominique

---

<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:** [September 16, 2020, 10:28am UTC](https://discuss.elastic.co/t/how-to-filter-a-field-with-entries-of-different-version-number-formats-in-elasticsearch-documents/245427/5 "2020-09-16T10:28:28Z")

</div>

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