• es创建索引及别名更新mapping方法 elasticsearch [nested] nested object under path [XXX] is not of nested type


    [nested] nested object under path [XXX] is not of nested type这是因为在创建索引时没有指定类型为数组,这就是一个大坑,ES官方说可以不用指定数字组类型,结果不指定的聚合结果还不一样!!!

    由于Elasticsearch底层使用了lucene的原因,不支持对mapping的修改,可使用索引重建的方式,升级版本的思路来做别名映射处理。
    1.创建索引 创建一个索引,这个索引的名称最好带上版本号,比如my_index_v1,my_index_v2等。
    my_index_v1 PUT
    {
    "settings": {
    "index.mapping.total_fields.limit": 2000,
    "number_of_shards": 5,
    "number_of_replicas": 1
    }
    "mappings": {
    "_doc": {
    ...
    }
    }

    2.索引复制,使用reindex api将旧索引数据导入新索引
    _reindex POST
    {
    "source": {
    "index": "my_index",
    "type": "_doc"
    },

    "dest": {
    "index": "my_index_v1",
    "type": "_doc"

    }
    }

    3.在视图确认已经创建且复制成功,然后删除原来的索引
    my_index  DELETE

    4.创建同之前的索引的相同名称的别名,不删除索引而创建同名的别名会报错“an index exists with the same name as the alias”
    /_aliases PUT
    {
    "actions": [
    { "add": {
    "alias": "my_index",
    "index": "my_index_v1"
    }}
    ]
    }
    如果需要删除别名
    /_aliases PUT
    {
    "actions": [
    { "remove": {
    "alias": "my_index",
    "index": "my_index_v1"
    }}
    ]
    }
    无缝切换
    {
    "actions": [
    { "remove": {
    "alias": "my_index",
    "index": "my_index_v1"
    }},
    { "add": {
    "alias": "my_index",
    "index": "my_index_v2"
    }}
    ]
    }

    5.查看别名
    _alias GET

    查看别名
    http://IP地址:9201/_cat/aliases

  • 相关阅读:
    tcp连接建立和断开
    端口状态说明 LISTENING、ESTABLISHED、TIME_WAIT及CLOSE_WAIT
    window IIS6/IIS7取消脚本执行权限,禁止运行脚本木马
    java 各种架构图汇总
    .NET平台常见技术框架整理汇总
    SQL Server中的Merge Into
    iText从LGPL改成AGPL历史来龙去脉
    工具系列 | 分布式日志管理graylog 实战
    目前博客使用的主题模板
    RLChina 文章
  • 原文地址:https://www.cnblogs.com/oktokeep/p/14476798.html
Copyright © 2020-2023  润新知