【问题标题】:ElasticSearch cannot find analyzer in field?ElasticSearch 在字段中找不到分析器?
【发布时间】:2016-06-20 15:55:49
【问题描述】:

我使用 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}

怎么了?

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    您的company 映射需要修复为:

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

    【讨论】:

      猜你喜欢
      • 2016-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-10
      • 2015-09-05
      • 1970-01-01
      相关资源
      最近更新 更多