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

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 :slight_smile: => smile

...any response will be appreciated

try char_filter instead of character_filter in the my_analyzer setup.

--Alex

@spinscale, that's it, thank you

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