es 不停机更新索引

更多内容请浏览本人博客

索引更新方法

1. 新建索引 product_v2          ==>  i 
2. 将老索引数据导入新索引         ==>  ii
3. 删除老索引别名,新建新索引别名   ==>  iii
i 新建产品索引

PUT /product_v2

{
    "settings": {
        "analysis": {
            "analyzer": {
                "ik": {
                    "tokenizer": "ik_smart"
                },
                "douhao": {
                    "tokenizer": "douhao_tokenizer"
                }
            },
            "tokenizer": {
                "douhao_tokenizer": {
                    "type": "pattern",
                    "pattern": ","
                }
            }
        }
    },
    "mappings": {
        "record": {
            "properties": {
                "productGoodsId": {
                    "type": "long"
                },
                "productName": {
                    "type": "text",
                    "analyzer": "ik_smart",
                    "search_analyzer": "ik_smart"
                },
                "originalPrice": {
                    "type": "double"
                },
                "promotionPrice": {
                    "type": "double"
                },
                "salesVolume": {
                    "type": "long"
                },
                "picturePath": {
                    "enabled": "false"
                },
                "selfSupport": {
                    "type": "long"
                },
                "eipMemberId": {
                    "type": "long"
                },
                "eipMemberName": {
                    "type": "text",
                    "analyzer": "ik_smart",
                    "search_analyzer": "ik_smart"
                },
                "clickVolume": {
                    "type": "long"
                },
                "isNew": {
                    "type": "long"
                },
                "updateTime": {
                    "type": "date",
                    "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
                },
                "categoryId": {
                    "type": "long"
                },
                "category_id_lv1": {
                    "type": "long"
                },
                "category_id_lv2": {
                    "type": "long"
                },
                "brand": {
                    "type": "keyword"
                },
                "specOptionName": {
                    "type": "text",
                    "analyzer": "douhao"
                },
                "unit": {
                    "enabled": "false"
                },
                "customCategoryId": {
                    "type": "text",
                    "analyzer": "douhao"
                },
                "gramWeight": {
                    "type": "double"
                },
                "kind": {
                    "type": "keyword"
                }
            }
        }
    }
}

ii 将老索引导入新索引办法

POST /_reindex

{"source":{"index":"products_v1"},"dest":{"index":"products_v2"}}
iii 新建索引别名方法

PUT /_aliases

{"actions":[{"remove":{"alias":"product","index":"products_v1"}},{"add":{"alias":"product","index":"products_v2"}}]}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值