# Match with or without thousands separator

**URL:** <https://discuss.elastic.co/t/match-with-or-without-thousands-separator/287183>\
**Category:** Elasticsearch\
**Created:** [October 20, 2021, 10:29am UTC](https://discuss.elastic.co/t/match-with-or-without-thousands-separator/287183 "2021-10-20T10:29:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Morten\_Sjogren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/morten_sjogren/32/83585_2.png) [@Morten\_Sjogren](https://discuss.elastic.co/u/Morten_Sjogren)\
**Post date:** [October 20, 2021, 10:29am UTC](https://discuss.elastic.co/t/match-with-or-without-thousands-separator/287183/1 "2021-10-20T10:29:44Z")

</div>

How do we match numbers in text-fields with and without thousands separators?

Use-case:

- The user searches for titles with one of "15000", "15,000" or "15.000"
- They expect to find items with titles like these:
  - "Historien om danskernes mad i 15.000 år" (a danish title)
  - "History for the last 15,000 years".

Is there a change we can make to our mapping that make this use-case possible?

```auto
      "DisplayTitle": {
        "fields": {
          "da": {
            "analyzer": "danish",
            "type": "text"
          },
          "de": {
            "analyzer": "german",
            "type": "text"
          },
          "en": {
            "analyzer": "english",
            "type": "text"
          },
          "fr": {
            "analyzer": "french",
            "type": "text"
          },
          "keyword": {
            "ignore_above": 256,
            "type": "keyword"
          }
        },
        "type": "text"
      },

```

We use `ElasticSearch 7.15`

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [October 20, 2021, 10:37am UTC](https://discuss.elastic.co/t/match-with-or-without-thousands-separator/287183/2 "2021-10-20T10:37:57Z")

</div>

Hi Morten,  
Adapted from the example in the [pattern replace token filter docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-pattern-replace-charfilter.html):

```auto
PUT my-index-00001
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "tokenizer": "standard",
          "char_filter": [
            "my_char_filter"
          ]
        }
      },
      "char_filter": {
        "my_char_filter": {
          "type": "pattern_replace",
          "pattern": "(\\d+),(?=\\d)",
          "replacement": "$1"
        }
      }
    }
  }
}

POST my-index-00001/_analyze
{
  "analyzer": "my_analyzer",
  "text": "My score is 12,000, yours is 11000 "
}

```

---

<div class="post-metadata">

**Author:** ![Morten\_Sjogren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/morten_sjogren/32/83585_2.png) [@Morten\_Sjogren](https://discuss.elastic.co/u/Morten_Sjogren)\
**Post date:** [October 20, 2021, 10:53am UTC](https://discuss.elastic.co/t/match-with-or-without-thousands-separator/287183/3 "2021-10-20T10:53:23Z")

</div>

> [@Mark\_Harwood](#):
>
> ```auto
> PUT my-index-00001
> {
> "settings": {
> "analysis": {
> "analyzer": {
> "my_analyzer": {
> "tokenizer": "standard",
> "char_filter": [
> "my_char_filter"
> ]
> }
> },
> "char_filter": {
> "my_char_filter": {
> "type": "pattern_replace",
> "pattern": "(\\d+),(?=\\d)",
> "replacement": "$1"
> }
> }
> }
> }
> }
> 
> ```

Thank you very much.

I made a small change to the pattern:

```auto

      "char_filter": {
        "my_char_filter": {
          "type": "pattern_replace",
          "pattern": "(\\d+)\\.(?=\\d{3})",
          "replacement": "$1"
        }
      }

```

---

<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:** [November 17, 2021, 10:54am UTC](https://discuss.elastic.co/t/match-with-or-without-thousands-separator/287183/4 "2021-11-17T10:54:08Z")

</div>

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