• 如何在Elasticsearch中删除中文索引


    问题现象

    因为某种特殊的原因,发现在es集群中出现了中文名称的索引,通过_cat API查询结果如下:

    GET /_cat/indices/?v
    
    health status index   uuid                   pri rep docs.count docs.deleted store.size pri.store.size
    green  open   rcp-b   nqTIHs6-SSG0K-Pa7guIIA   5   0          1            0        4kb            4kb
    green  open   .kibana T4aQP8DTT72aS0qrg7k_-w   1   0         19            3     64.6kb         64.6kb
    red  open   测试索引中文 T4aQP8DTT99aS0qrg7k_-w   5   1         19            3     64.6kb         64.6kb
    
    

    直接用DELETE API 删除报错

    DELETE /测试索引中文
    
    {
      "error": {
        "root_cause": [
          {
            "type": "index_not_found_exception",
            "reason": "no such index",
            "index_uuid": "_na_",
            "resource.type": "index_or_alias",
            "resource.id": "KÕ"u0015-‡",
            "index": "KÕ"u0015-‡"
          }
        ],
        "type": "index_not_found_exception",
        "reason": "no such index",
        "index_uuid": "_na_",
        "resource.type": "index_or_alias",
        "resource.id": "KÕ"u0015-‡",
        "index": "KÕ"u0015-‡"
      },
      "status": 404
    }
    

    如何删除这个"测试索引中文" 的索引呢 ?

    思路就是用别名API(_alias)将这个中文索引,别名成英文,然后再用DELETE API删除

    POST /_aliases
    {
        "actions" : [
            { "add" : { "index" : "测试索引中文", "alias" : "testcn" } }
        ]
    }
    
    DELETE /testcn
    
    
  • 相关阅读:
    日常记Bug
    Docker部署Django
    杂记:防火墙、企业微信登陆、RestFrameWork
    Python2和Python3的编码
    杂记:Django和static,Nginx配置路径,json_schema
    xlwt模块的使用
    企业微信登陆
    markdown八条基础语法
    webstorm 添加markdown支持
    【electron系列之二】复制图片
  • 原文地址:https://www.cnblogs.com/wangzhen3798/p/11152929.html
Copyright © 2020-2023  润新知