首页 文章

创建索引时Analyzer中的错误

提问于
浏览
1

我正在尝试使用以下设置在elasticsearch中创建索引 . 我面临以下错误

错误:RemoteTransportException [[ys2order-stg2-01] [inet [/64.101.206.15:9300]] [indices:admin / mapping / put]];嵌套:MapperParsingException [找不到字段[DESCRIPTION_AUTO]]的Analyzer [autocomplete]];状态:400

{
  "settings": {
    "index": {
      "analysis": {
        "filter": {
          "autocomplete_filter": {
            "type": "edge_ngram",
            "min_gram": 1,
            "max_gram": 20
          }
        },
        "analyzer": {
          " autocomplete": {
            "type": "custom",
            "filter": [
              "lowercase",
              "autocomplete_filter"
            ],
            "tokenizer": "standard"
          }
        }
      },
      "refresh_interval": -1,
      "number_of_replicas": 1,
      "number_of_shards": 4,
      "index_analyzer": "default_index",
      "search_analyzer": "default_search"
    }
  },
  "mappings": {
    "itemsnew": {
      "properties": {
        "DESCRIPTION_AUTO": {
          "index_analyzer": "autocomplete",
          "search_analyzer": "standard",
          "type": "string"
        }
      }
    }
  }
}

1 回答

  • 0

    您需要删除分析仪名称中的空格:

    "analyzer": {
          " autocomplete": {       <--- remove initial space here
            "type": "custom",
            "filter": [
              "lowercase",
              "autocomplete_filter"
            ],
            "tokenizer": "standard"
          }
        ....
        "DESCRIPTION_AUTO": {
          "index_analyzer": "autocomplete",   <-- because there is no initial space here !!!
          "search_analyzer": "standard",
          "type": "string"
        }
    

相关问题