# Custom analyzer not working

**URL:** <https://discuss.elastic.co/t/custom-analyzer-not-working/138396>\
**Category:** Elasticsearch\
**Created:** [July 3, 2018, 1:04pm UTC](https://discuss.elastic.co/t/custom-analyzer-not-working/138396 "2018-07-03T13:04:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fhalde](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fhalde/32/21419_2.png) [@fhalde](https://discuss.elastic.co/u/fhalde)\
**Post date:** [July 3, 2018, 1:04pm UTC](https://discuss.elastic.co/t/custom-analyzer-not-working/138396/1 "2018-07-03T13:04:14Z")

</div>

I'm using the below mapping where the payload.body field will contain json as a string. i want to get rid of all the braces, quotes colons e.t.c from the json and leave out only the keys [the values will be empty string all the time]. but for some reason the char mapping is not working

e.g. {"query": {match\_all: ''}} returns querymatch\_all

```
{
  "order": 0,
  "template": "custom_stats*",
  "settings": {
    "index": {
      "analysis": {
        "analyzer": {
          "query_logging_analyzer": {
            "char_filter": [
              "json_entites"
            ],
            "tokenizer": "whitespace"
          }
        },
        "char_filter": {
          "json_entites": {
            "type": "mapping",
            "mappings": [
              "{=> ",
              "}=> ",
              "'=> ",
              "\"=> ",
              ":=> ",
              ",=> ",
              "[=> ",
              "]=> "
            ]
          }
        }
      }
    }
  },
  "mappings": {
    "logs": {
      "properties": {
        "payload": {
          "properties": {
            "body": {
              "index": "not_analyzed",
              "type": "string",
              "fields": {
                "features": {
                  "analyzer": "query_logging_analyzer",
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "aliases": {}
}
```

---

<div class="post-metadata">

**Author:** ![klof](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klof/32/31590_2.png) [@klof](https://discuss.elastic.co/u/klof)\
**Post date:** [July 3, 2018, 1:32pm UTC](https://discuss.elastic.co/t/custom-analyzer-not-working/138396/2 "2018-07-03T13:32:46Z")

</div>

No needs to create a mapping filter for that.  
The standard analyzer will exclude all these special characters!

```
GET index/_analyze
{
  "text": "{\"query\": {match_all: ''}}",
  "field": "body"
}
```

---

<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:** [July 31, 2018, 1:32pm UTC](https://discuss.elastic.co/t/custom-analyzer-not-working/138396/3 "2018-07-31T13:32:47Z")

</div>

Closed on July 31, 2018, 1:32pm UTC

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