Exclude mode settings example

edit

Exclude mode settings example

edit

If the mode parameter is set to exclude like in the following example:

PUT /keep_types_exclude_example
{
    "settings" : {
        "analysis" : {
            "analyzer" : {
                "my_analyzer" : {
                    "tokenizer" : "standard",
                    "filter" : ["lowercase", "remove_numbers"]
                }
            },
            "filter" : {
                "remove_numbers" : {
                    "type" : "keep_types",
                    "mode" : "exclude",
                    "types" : [ "<NUM>" ]
                }
            }
        }
    }
}

And we test it like:

POST /keep_types_exclude_example/_analyze
{
  "analyzer" : "my_analyzer",
  "text" : "hello 101 world"
}

The response will be:

{
  "tokens": [
    {
      "token": "hello",
      "start_offset": 0,
      "end_offset": 5,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "world",
      "start_offset": 10,
      "end_offset": 15,
      "type": "<ALPHANUM>",
      "position": 2
    }
  ]
}