ElasticSearch在现场找不到分析仪?

时间:2016-06-20 15:55:49

标签: elasticsearch

我使用PUT http://localhost:9200/test

创建这样的索引
{
  "settings": {
    "number_of_shards": 1,
    "analysis": {
      "analyzer": {
        "sortable": {
          "type": "custom",
          "tokenizer": "keyword",
          "filter": [
            "lowercase"
          ]
        }
      }
    }
  },
  "mappings": {
  }
}

这返回:

{"acknowledged":true}

然后确保分析仪在那里: http://localhost:9200/test/_analyze?_analyzer=sortable&text=HeLLo

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

所以我为它创建了映射: 通过PUT http://localhost:9200/test/_mapping/company

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

返回:

{"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}

有什么问题?

1 个答案:

答案 0 :(得分:1)

您的company映射需要修复此问题:

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