代码之家  ›  专栏  ›  技术社区  ›  ThomasThiebaud

我可以在不指定路由密钥的情况下批量删除文档吗?

  •  0
  • ThomasThiebaud  · 技术社区  · 5 年前

    我在用 python-elasticsearch ( https://elasticsearch-py.readthedocs.io/en/master/ )在具有多个分片的ES集群上批量插入文档。我正在使用 routing 在插入过程中,但删除时我无法访问该密钥

    有办法击中所有碎片吗?类似的东西 routing=* 。如果我没有指定路由密钥,ES将无法找到该文档

    这个

    POST _bulk
    { "index" : { "_index" : "test", "_id" : "1", "routing": "1" } }
    { "field1" : "value1" }
    { "delete" : { "_index" : "test", "_id" : "2" } } // Fails because routing is missing
    

    给我

    {
      "took" : 1334,
      "errors" : false,
      "items" : [
        {
          "index" : {
            "_index" : "test",
            "_type" : "_doc",
            "_id" : "1",
            "_version" : 1,
            "result" : "created",
            "_shards" : {
              "total" : 2,
              "successful" : 1,
              "failed" : 0
            },
            "_seq_no" : 0,
            "_primary_term" : 1,
            "status" : 201
          }
        },
        {
          "delete" : {
            "_index" : "test",
            "_type" : "_doc",
            "_id" : "2",
            "_version" : 1,
            "result" : "not_found",
            "_shards" : {
              "total" : 2,
              "successful" : 1,
              "failed" : 0
            },
            "_seq_no" : 0,
            "_primary_term" : 1,
            "status" : 404
          }
        }
      ]
    }
    
    0 回复  |  直到 5 年前