欢迎投稿

今日深度:

ElasticSearch 学习笔记:Reindex,

ElasticSearch 学习笔记:Reindex,


1、创建新的索引(Index):

PUT /<indexName>
{
  "settings": {
    "index": {
      "number_of_shards": 5,
      "number_of_replicas": 1
    }
  }
}

2、导入数据(Reindex):

POST /_reindex
{
  "source": {
    "index": "<sourceIndexName>",
    "type": "<sourceTypeName>",
    "sort": {
      "<fieldName>": "asc/desc"
    },
    "_source": [
      "<fieldName>",
      "<fieldName>",
      ...
    ]
  },
  "dest": {
    "index": "<destIndexName>"
  }
}

3、批量更新(Update by Query):

POST /<indexName>/<typeName>/_update_by_query
{
  "query": {
    "match_all": {}
  },
  "script": {
    "inline/source": "ctx._source.<fieldName> = ctx._source.<fieldName> + ''"
  }
}

inline:ES 5.6版本之前;

source:ES 5.6版本及以后


4、新建/删除别名(Alias):

POST /_aliases
{
  "actions": [
    {
      "add": {
        "index": "<indexName>",
        "alias": "<alias>"
      }
    }
  ]
}

{
  "actions": [
    {
      "remove": {
        "index": "<indexName>",
        "alias": "<alias>"
      }
    }
  ]
}


www.htsjk.Com true http://www.htsjk.com/Elasticsearch/36495.html NewsArticle ElasticSearch 学习笔记:Reindex, 1、创建新的索引(Index): PUT /indexName{ "settings": { "index": { "number_of_shards": 5, "number_of_replicas": 1 } }} 2、导入数据(Reindex): POST /_reindex{ "source": { "index":...
相关文章
    暂无相关文章
评论暂时关闭