# Using analyzer defined in index leads not to the same result when using \_analyze API

**URL:** https://discuss.elastic.co/t/using-analyzer-defined-in-index-leads-not-to-the-same-result-when-using-analyze-api/216834
**Category:** Elasticsearch
**Created:** [January 28, 2020, 12:41pm UTC](https://discuss.elastic.co/t/using-analyzer-defined-in-index-leads-not-to-the-same-result-when-using-analyze-api/216834 "2020-01-28T12:41:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![itarch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/itarch/32/61534_2.png) [@itarch](https://discuss.elastic.co/u/itarch)
#### Post date: [January 28, 2020, 12:41pm UTC](https://discuss.elastic.co/t/using-analyzer-defined-in-index-leads-not-to-the-same-result-when-using-analyze-api/216834/1 "2020-01-28T12:41:05Z")

</div>

Hi,

need some help please!  
I expect that **A)** and **B)** leads to the same result.  
However, in A), using the \_analayze API leads to what I expect. In B), defining "my\_analyzer" like i do in A) in "mytest01" index do not lead to same result.  
Why is that so?  
(Im using ES 7.4.1 and Kibana 7.4.2)

**A)**

```
GET _analyze
{
  "char_filter": [
    {
      "type" : "mapping",
      "mappings" : [":) => _smile1_"]
    }
  ],
  "tokenizer": "standard",
  "text": "Hello World :)"
}

```

\*\*\* Returns

```
{
  "tokens" : [
    {
      "token" : "Hello",
      "start_offset" : 0,
      "end_offset" : 5,
      "type" : "<ALPHANUM>",
      "position" : 0
    },
    {
      "token" : "World",
      "start_offset" : 6,
      "end_offset" : 11,
      "type" : "<ALPHANUM>",
      "position" : 1
    },
    {
      "token" : "_smile1_",
      "start_offset" : 12,
      "end_offset" : 14,
      "type" : "<ALPHANUM>",
      "position" : 2
    }
  ]
}

```

**B)** Defined in an index

```
PUT mytest01
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer" : {
          "type" : "custom",
          "character_filter" : "my_cfilter",
          "tokenizer" : "standard"
        }
      },
      "char_filter": {
        "my_cfilter": {
          "type" : "mapping",
          "mappings" : [":) => _smile_"]
        }
      }
    }
  }
}

POST mytest01/_analyze
{
  "analyzer": "my_analyzer",
  "text": "Hello World :)"
}

```

\*\*\* returns

```
{
  "tokens" : [
    {
      "token" : "Hello",
      "start_offset" : 0,
      "end_offset" : 5,
      "type" : "<ALPHANUM>",
      "position" : 0
    },
    {
      "token" : "World",
      "start_offset" : 6,
      "end_offset" : 11,
      "type" : "<ALPHANUM>",
      "position" : 1
    }
  ]
}

```

I miss the 3rd token beeing mapped from 🙂 =\> _smile_

...any response will be appreciated

---

<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: [January 28, 2020, 2:17pm UTC](https://discuss.elastic.co/t/using-analyzer-defined-in-index-leads-not-to-the-same-result-when-using-analyze-api/216834/2 "2020-01-28T14:17:41Z")

</div>

try `char_filter` instead of `character_filter` in the `my_analyzer` setup.

--Alex

---

<div class="post-metadata">

### Author: ![itarch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/itarch/32/61534_2.png) [@itarch](https://discuss.elastic.co/u/itarch)
#### Post date: [January 29, 2020, 7:19am UTC](https://discuss.elastic.co/t/using-analyzer-defined-in-index-leads-not-to-the-same-result-when-using-analyze-api/216834/3 "2020-01-29T07:19:30Z")

</div>

@spinscale, that's it, thank you

---

<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: [February 26, 2020, 7:19am UTC](https://discuss.elastic.co/t/using-analyzer-defined-in-index-leads-not-to-the-same-result-when-using-analyze-api/216834/4 "2020-02-26T07:19:34Z")

</div>

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