Vikas Pandya
Vikas Pandya

Reputation: 1988

analyzer not found when creating index mapping

when an index was created new analyzer was added analyzer_keyword - see below create index

curl -XPUT 'http://mycluster/dsi2' -d '{
  "settings": {
    "index": {
      "number_of_shards": 1,
      "number_of_replicas": 1,
      "analysis": {
        "analyzer": {
          "analyzer_keyword": {
            "tokenizer": "keyword",
             "filter": "lowercase"
          }
        }
      }
    }
  }
}

Running _settings endpoint confirms following

http GET http://mycluster/dsi2/_settings
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 267
Content-Type: application/json; charset=UTF-8

{
    "dsi2": {
        "settings": {
            "index": {
                "analysis": {
                    "analyzer": {
                        "analyzer_keyword": {
                            "filter": "lowercase", 
                            "tokenizer": "keyword"
                        }
                    }
                }, 
                "creation_date": "1484088347598", 
                "number_of_replicas": "1", 
                "number_of_shards": "1", 
                "uuid": "Lu98fn6gRiOe3Q1y8fU6tQ", 
                "version": {
                    "created": "2030299"
                }
            }
        }
    }
}

but now when creating mapping - (following is partial mapping json with relevant fields )

curl -XPUT 'http://mycluster/_mapping/dsi2' -d '{
  "_all": {
    "enabled": true
  },
  "properties": {
    "mainId" : {
      "type" : "integer"
      },

    "instance": {
      "properties": {
        "id": {
          "type": "integer",
          "fields": {
            "raw": {
              "type": "integer",
              "index": "not_analyzed"
            }

it throws

[{"error":{"root_cause": [{"type":"mapper_parsing_exception","reason":"analyzer [analyzer_keyword] not found for field [raw]"}],"type":"mapper_parsing_exception","reason":"analyzer [analyzer_keyword] not found for field [raw]"},"status":400}

any idea why it's not able to find analyzer_keyword mapping that was created part of index? this is against Amazon EC2 ElasticService instance with Elastic version 2.3

EDIT - Thanks Val for the response.

@Val - thanks for the response. after recreating index as you pointed out - I am still getting same error while creating mapping. when I run GET http://mycluster/dsi2/_settings it shows me following

{
    "dsi2": {
        "settings": {
            "index": {
                "analysis": {
                    "analyzer": {
                        "analyzer_keyword": {
                            "filter": "lowercase", 
                            "tokenizer": "keyword"
                        }
                    }
                }, 
                "creation_date": "1484146006348", 
                "number_of_replicas": "1", 
                "number_of_shards": "1", 
                "uuid": "HzjQjZXmS8SPF6yUFZanEQ", 
                "version": {
                    "created": "2030299"
                }
            }
        }
    }
}

Upvotes: 5

Views: 13024

Answers (1)

Val
Val

Reputation: 217304

That's because the analysis section goes directly under settings and not settings > index.

You can recreate your index like this and it will work:

curl -XPUT 'http://mycluster/dsi2' -d '{
  "settings": {
    "index": {
      "number_of_shards": 1,
      "number_of_replicas": 1
    },
    "analysis": {
      "analyzer": {
        "analyzer_keyword": {
          "tokenizer": "keyword",
          "filter": "lowercase"
        }
      }
    }
  }
}

Upvotes: 10

Related Questions