找不到elasticsearch edge_ngrams分析器

时间:2016-02-23 23:41:18

标签: elasticsearch

我正在关注elasticsearch的官方视频

他们说要这样做:

PUT /blablabla/doc/_mapping
{
  "properties": {
    "title" : {
      "type": "string",
      "fields": {
        "stemmed" : {
          "type": "string",
          "analyzer": "english"
        },
        "autocomplete" : {
          "type": "string",
          "analyzer": "edge_ngrams"
        }
      }
    }
  }
}

我得到分析器edge_ngrams不存在的错误

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

为什么好吗? 我正在使用elasticsearch 2.2

更新

调用GET /blablabla我得到以下内容

{
  "blablabla": {
    "aliases": {},
    "mappings": {
      "doc": {
        "properties": {
          "job": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      }
    },
    "settings": {
      "index": {
        "creation_date": "1456267981541",
        "number_of_shards": "5",
        "number_of_replicas": "1",
        "uuid": "5042-5UwR42QY45jMRw8jQ",
        "version": {
          "created": "2010199"
        }
      }
    },
    "warmers": {}
  }
}

1 个答案:

答案 0 :(得分:0)

分析器的正确名称为edgeNGram而不是edge_ngrams。结帐link

min_gram和max_gram的默认值分别为1和2。在大多数情况下,您可能需要提供自定义分析器。

您可以在此reference

查看如何执行此操作