elasticsearch - 将分析器添加到 elasticsearch 6.3.1 中的现有索引

标签 elasticsearch

我正在尝试在 elasticsearch 的现有索引中添加分析器。

下面是代码 :-

curl -X POST "localhost:9200/existing_index_name/_mapping/_doc?pretty" -H 'Content-Type:     application/json' -d'
{
"settings":{
    "analysis":{
    "analyzer":{
    "analyzer_startswith":{
    "tokenizer":"keyword",
    "filter":["lowercase"]
     }
    }
   }      
  }
 }
'

以下是我遇到的错误:-

 ["type" : "mapper_parsing_exception",
        "reason" : "Root mapping definition has unsupported parameters:  [settings : {analysis={analyzer={analyzer_startswith={tokenizer=keyword, filter=[lowercase]}}}}]"

最佳答案

您需要调用 _settings endpoint不是 _mapping 一个:

                                                change this
                                                     |
                                                     v
curl -X POST "localhost:9200/existing_index_name/_settings?pretty" -H 'Content-Type: application/json' -d'{
  "analysis": {
    "analyzer": {
      "analyzer_startswith": {
        "tokenizer": "keyword",
        "filter": [
          "lowercase"
        ]
      }
    }
  }
}

但是请注意,您需要先关闭索引:

curl -XPOST http://localhost:9200/existing_index_name/_close

然后更新设置后,需要再次打开

curl -XPOST http://localhost:9200/existing_index_name/_open

关于elasticsearch - 将分析器添加到 elasticsearch 6.3.1 中的现有索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58110981/

相关文章:

python - Elasticsearch 未显示字段

java - Elasticsearch Java api - 选择查询以搜索混合有特殊字符的文本(John-son)

elasticsearch - 嵌入式Elasticsearch-第二次启动需要很长时间

python - 使用Elasticsearch DSL Python的复合Elasticsearch聚合

symfony - 您可以在同一实体的不同索引中定义两个或多个类型吗?

elasticsearch - ElasticSearch 2.1.0-带有 'children'指标的深度 'sum'聚合返回空结果

ElasticSearch - 尝试在 Windows 上启动服务时出错

elasticsearch - elasticsearch通过子聚合doc_count排除聚合桶

amazon-web-services - ElasticSearch 的缩放

elasticsearch - 我可以在一个 Elasticsearch 索引设置中有多个过滤器吗?