zoukankan      html  css  js  c++  java
  • elasticsearch7.x-reindex

    同一集群条件查询一个索引的数据插入到另一个索引

    限制条件:指定需要的字段及确定的返回数据条数

    示例:

    POST _reindex
    {
      "size": 5,
      "source": {
        "index": "movies",
        "_source": [
          "genre",
          "title"
        ],
        "sort": {
          "genre.keyword": "desc"
        },
        "query": {
          "match": {
            "title": "Dracula"
          }
        }
      },
      "dest": {
        "index": "reindex_20210306"
      }
    }

    结果:

    {
      "took" : 1,
      "timed_out" : false,
      "_shards" : {
        "total" : 1,
        "successful" : 1,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : {
          "value" : 5,
          "relation" : "eq"
        },
        "max_score" : 1.0,
        "hits" : [
          {
            "_index" : "reindex_20210306",
            "_type" : "_doc",
            "_id" : "1339",
            "_score" : 1.0,
            "_source" : {
              "genre" : [
                "Fantasy",
                "Horror",
                "Romance",
                "Thriller"
              ],
              "title" : "Dracula"
            }
          },
          {
            "_index" : "reindex_20210306",
            "_type" : "_doc",
            "_id" : "6665",
            "_score" : 1.0,
            "_source" : {
              "genre" : [
                "Horror",
                "Romance"
              ],
              "title" : "Dracula"
            }
          },
          {
            "_index" : "reindex_20210306",
            "_type" : "_doc",
            "_id" : "2653",
            "_score" : 1.0,
            "_source" : {
              "genre" : [
                "Horror"
              ],
              "title" : "Son of Dracula"
            }
          },
          {
            "_index" : "reindex_20210306",
            "_type" : "_doc",
            "_id" : "2644",
            "_score" : 1.0,
            "_source" : {
              "genre" : [
                "Horror"
              ],
              "title" : "Dracula"
            }
          },
          {
            "_index" : "reindex_20210306",
            "_type" : "_doc",
            "_id" : "4030",
            "_score" : 1.0,
            "_source" : {
              "genre" : [
                "Horror"
              ],
              "title" : "Dracula 2000"
            }
          }
        ]
      }
    }

    官方地址:https://www.elastic.co/guide/en/elasticsearch/reference/7.2/docs-reindex.html

  • 相关阅读:
    GIL锁、进程池和线程池、同步和异步
    线程
    socket编程
    单例模式
    反射、自定义内置方法来定制类的功能、元类
    elasticSearch(一)--数据1
    docker学习整理(三)
    docker学习整理(二)
    docker学习整理(一)
    IDEA 配置mybatis生成代码
  • 原文地址:https://www.cnblogs.com/zxbdboke/p/14563605.html
Copyright © 2011-2022 走看看