fang
fang

Reputation: 617

Custom analyzer with lowercase filter doesn't work as expected

I have a simple custom analyzer called custom_raw_analyzer like this:

$ curl 'http://localhost:9200/test/_settings?pretty'

  "test" : {
    "settings" : {
      "index" : {
        "uuid" : "_M-KXnZSQXyFH7cqbh6lsw",
        "number_of_replicas" : "1",
        "analysis" : {
          "analyzer" : {
            "custom_raw_analyzer" : {
              "type" : "custom",
              "filters" : [ "lowercase" ],
              "tokenizer" : "keyword"
            }
          }
        },
        "number_of_shards" : "5",
        "refresh_interval" : "10s",
        "version" : {
          "created" : "1030499"
        }
      }
    }
  }
}

But when I did a test on a random string, the output tokens are not lowercase:

$ curl -XGET 'localhost:9200/test/_analyze?analyzer=custom_raw_analyzer' -d "This Is A Test"

result:

{
  "tokens": [
    {
      "token": "This Is A Test",
      "start_offset": 0,
      "end_offset": 14,
      "type": "word",
      "position": 1
    }
  ]
}

Can anybody explain why ?

Upvotes: 0

Views: 382

Answers (1)

Olly Cruickshank
Olly Cruickshank

Reputation: 6180

I think you have a typo:

"filters" : [ "lowercase" ],

Should not have a trailing "s":

"filter" : [ "lowercase" ],

Upvotes: 1

Related Questions