当我想更新索引的设置以添加char过滤器时,我在elasticSearch上遇到错误,该过滤器应该在索引和搜索上用“ - ”替换空格 .

这是我在日志中的错误:

[app] [4]收到[app] [4],节点[eJuT9n88QIqNC_8fZhmo6A],[P],s [INITIALIZING],unassigned_info [[reason = ALLOCATION_FAILED],[2016-04-11T09:53:]: 14.756Z],详细信息[shard failure [创建索引失败] [IndexCreationException [[app]创建索引失败];嵌套:ElasticsearchIllegalArgumentException [标记过滤器[char_filter]必须具有与之关联的类型]; ]],indexUUID [eQrTAVxGS6uJmiMfKqRxNQ],原因[shard failure [创建索引失败] [IndexCreationException [[app]创建索引失败];嵌套:ElasticsearchIllegalArgumentException [标记过滤器[char_filter]必须具有与之关联的类型]; ]]

这是我更新设置的方式:

PUT /app/_settings
{
   "analysis": {
      "char_filter": {
         "spaces": {
            "type": "pattern_replace",
            "pattern": "/ /g",
            "replacement": "-"
         }
      },
      "analyzer": {
         "marque_index": {
            "type": "custom",
            "tokenizer": "standard",
            "char_filter": [
               "spaces"
            ],
            "filter": [
               "trim",
               "lowercase"
            ]
         },
         "marque_search": {
            "type": "custom",
            "tokenizer": "standard",
            "char_filter": [
               "spaces"
            ],
            "filter": [
               "trim",
               "lowercase"
            ]
         }
      }
   }
}

我的ES版本:1.7.5

有两天我坚持了 . 我尝试了所有的东西,并根据这份文档开展工作:

ES pattern replaceES custom analyzers

  • 小更新:

当我请求索引的设置时,我得到了什么: GET /app/_settings

{
   "app": {
      "settings": {
         "index": {
            "creation_date": "1460370729368",
            "uuid": "zRfx6USRSfazbLLyIHbqnw",
            "analysis": {
               "char_filter": {
                  "spaces": {
                     "type": "pattern_replace",
                     "pattern": "/ /g",
                     "replacement": "-"
                  }
               },
               "analyzer": {
                  "marque_search": {
                     "type": "custom",
                     "char_filter": [
                        "spaces"
                     ],
                     "filter": [
                        "trim",
                        "lowercase"
                     ],
                     "tokenizer": "standard"
                  },
                  "marque_index": {
                     "type": "custom",
                     "char_filter": [
                        "spaces"
                     ],
                     "filter": [
                        "trim",
                        "lowercase"
                     ],
                     "tokenizer": "standard"
                  }
               }
            },
            "number_of_replicas": "1",
            "number_of_shards": "5",
            "version": {
               "created": "1070599"
            }
         }
      }
   }
}

一切看起来都不错......

在此先感谢您的帮助 .