user3384741
user3384741

Reputation: 1340

ElasticSearch cannot find analyzer in field?

I create an index like this using a PUT http://localhost:9200/test :

{
  "settings": {
    "number_of_shards": 1,
    "analysis": {
      "analyzer": {
        "sortable": {
          "type": "custom",
          "tokenizer": "keyword",
          "filter": [
            "lowercase"
          ]
        }
      }
    }
  },
  "mappings": {
  }
}

This returned:

{"acknowledged":true}

Then make sure that the analyzer is there: http://localhost:9200/test/_analyze?_analyzer=sortable&text=HeLLo

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

So I create mappings for it: By PUT http://localhost:9200/test/_mapping/company

{
  "properties": {
    "name": {
      "type": "string",
      "analyzer": "standard",
      "fields": {
        "raw": {
          "type": {
            "analyzer": "sortable"
          }
        }
      }
    }
}

This returns:

{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"no handler for type [{analyzer=sortable}] declared on field [raw]"}],"type":"mapper_parsing_exception","reason":"no handler for type [{analyzer=sortable}] declared on field [raw]"},"status":400}

What is wrong?

Upvotes: 0

Views: 254

Answers (1)

Val
Val

Reputation: 217514

Your company mapping needs to be fixed to this:

{
  "properties": {
    "name": {
      "type": "string",
      "analyzer": "standard",
      "fields": {
        "raw": {
          "type": "string",
          "analyzer": "sortable"
        }
      }
    }
}

Upvotes: 2

Related Questions