# Pattern\_filter for removing dots from a number

**URL:** <https://discuss.elastic.co/t/pattern-filter-for-removing-dots-from-a-number/105575>\
**Category:** Elasticsearch\
**Created:** [October 27, 2017, 1:16pm UTC](https://discuss.elastic.co/t/pattern-filter-for-removing-dots-from-a-number/105575 "2017-10-27T13:16:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![guilherme\_maranhao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guilherme_maranhao/32/101483_2.png) [@guilherme\_maranhao](https://discuss.elastic.co/u/guilherme_maranhao)\
**Post date:** [October 27, 2017, 1:16pm UTC](https://discuss.elastic.co/t/pattern-filter-for-removing-dots-from-a-number/105575/1 "2017-10-27T13:16:03Z")

</div>

Hi everyone,

I am using elasticsearch version 5.5.2 .  
I using GET /\_analyze API to test a pattern\_replace filter.  
I just need to remove all dots from a number. What I am trying to do is:

```
GET /_analyze
{
     "char_filter":[{"type": "pattern_replace", "pattern":"[.]+","replacement":""}],
     "text":"22400.6545421.54541.6545"
}

```

The response is

```
{
    "tokens": [
        {
            "token": "22400.6545421.54541.6545",
            "start_offset": 1,
            "end_offset": 25,
            "type": "<NUM>",
            "position": 0
        }
    ]
}

```

The regExp seems to be correct, according to  
[http://rubular.com/](http://rubular.com/)  
[http://www.regexplanet.com/advanced/java/index.html](http://www.regexplanet.com/advanced/java/index.html)

Do I need to specify any tokenizer? If I do so, I got

```
GET /_analyze
{
     "tokenizer":"standard",
     "char_filter":[{"type": "pattern_replace", "pattern":"[.]+","replacement":""}],
     "text":"22400.6545421.54541.6545"
}

```

Exception

```
{
    "error": {
        "root_cause": [
            {
                "type": "remote_transport_exception",
                "reason": "[uaWbxRq][127.0.0.1:9300][indices:admin/analyze[s]]"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "failed to find global token filter under [[{\"type\": \"pattern_replace\"]"
    },
    "status": 400
}

```

What am I doing wrong? Why aren't the dots being removed?

Thanks a lot,

Guilherme

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 27, 2017, 3:53pm UTC](https://discuss.elastic.co/t/pattern-filter-for-removing-dots-from-a-number/105575/2 "2017-10-27T15:53:01Z")

</div>

try

```auto
GET /_analyze
{
  "char_filter": [
    {
      "type": "pattern_replace",
      "pattern": "\\.",
      "replacement": ""
    }
  ],
  "tokenizer": "keyword", 
  "text": "22400.6545421.54541.6545"
}

```

The docs state in a warning (I suppose that's what you hit)

> tokenizer is mandatory when using char\_filter or filter. If it is not set, the filters are ignored and the default analyzer is used.

--Alex

---

<div class="post-metadata">

**Author:** ![guilherme\_maranhao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guilherme_maranhao/32/101483_2.png) [@guilherme\_maranhao](https://discuss.elastic.co/u/guilherme_maranhao)\
**Post date:** [October 27, 2017, 4:43pm UTC](https://discuss.elastic.co/t/pattern-filter-for-removing-dots-from-a-number/105575/3 "2017-10-27T16:43:34Z")

</div>

Thank you, @spinscale, but as said before, if I set the tokenizer parameter, I got 400 exception.

```
{
    "error": {
        "root_cause": [
            {
                "type": "remote_transport_exception",
                "reason": "[uaWbxRq][127.0.0.1:9300][indices:admin/analyze[s]]"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "failed to find global token filter under [[{\"type\": \"pattern_replace\"]"
    },
    "status": 400
} 

```

I'm using Postman as my client to test the requests.

 ![53](https://us1.discourse-cdn.com/elastic/original/3X/3/4/34f3f188cd2f59430922c11f151f2ba20ac4a842.png)

I suppose I'm passing the parameters in a wrong way, isn't it?

Why do I get that??

```
"type": "illegal_argument_exception",
"reason": "failed to find global token filter under [[{\"type\": \"pattern_replace\"]"

```

Thank you very much,

Guilherme

---

<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 24, 2017, 4:44pm UTC](https://discuss.elastic.co/t/pattern-filter-for-removing-dots-from-a-number/105575/4 "2017-11-24T16:44:19Z")

</div>

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