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

怎么了?

最佳答案

您的company映射需要固定为此:

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

关于elasticsearch - ElasticSearch在现场找不到分析仪?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37926849/

10-11 09:01
查看更多