使用_reindex API从搜索结果创建索引

发布于 2025-01-26 20:00:56 字数 601 浏览 5 评论 0原文

我正在将我的搜索请求结果存储在新索引中。 这是我的代码:

POST /_reindex
{ 
  "source": {
    "index": "my_index_name",
    "query": {
    "bool": {
      "must": [
        {
          "match": {
            "host.hostname": "value_1"
          }
        },
        {
          "match": {
            "message": "value_a"
          }
        }
      ]
    }
  },
   "size":3
  },
  "dest": {
    "index": "new_test"
  }
}

此请求仅限于3个。但是,尺寸限制未考虑。因此,此消息的后请求结果是502错误:

{"ok":false,"message":"backend closed connection"}

我的问题是如何将上述请求结果存储在Elasticsearch的新索引中? 预先感谢您的帮助。

I'am tring to store the results of my search request in new index.
This is my code:

POST /_reindex
{ 
  "source": {
    "index": "my_index_name",
    "query": {
    "bool": {
      "must": [
        {
          "match": {
            "host.hostname": "value_1"
          }
        },
        {
          "match": {
            "message": "value_a"
          }
        }
      ]
    }
  },
   "size":3
  },
  "dest": {
    "index": "new_test"
  }
}

This request is limited to a size of 3. However the size limit is not taken into account. Hence the Post request result is 502 error with this message:

{"ok":false,"message":"backend closed connection"}

My question is how can i store the result of the request above in a new index in ELasticsearch?
Thank you in advance for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

作业与我同在 2025-02-02 20:00:56

您需要将max_docs参数设置为请求。

POST _reindex
{
  "max_docs": 1,
  "source": {
    "index": "my-index-000001"
  },
  "dest": {
    "index": "my-new-index-000001"
  }
}

size参数是用于每批索引的文档数量。

默认情况下_reindex使用1000的卷轴。您可以更改
带有源元素中尺寸字段的批量尺寸

You need to set max_docs param to your request.

POST _reindex
{
  "max_docs": 1,
  "source": {
    "index": "my-index-000001"
  },
  "dest": {
    "index": "my-new-index-000001"
  }
}

size param is for number of documents to index per batch.

By default _reindex uses scroll batches of 1000. You can change the
batch size with the size field in the source element

往日情怀 2025-02-02 20:00:56

您需要指定顶级 max_docs参数而不是source.size

POST /_reindex
{
  "max_docs": 3,
  "source": {
    "index": "my_index_name",
    "query": {
      "bool": {
        "must": [
          {
            "match": {
              "host.hostname": "value_1"
            }
          },
          {
            "match": {
              "message": "value_a"
            }
          }
        ]
      }
    }
  },
  "dest": {
    "index": "new_test"
  }
}

You need to specify the top-level max_docs parameter instead of source.size:

POST /_reindex
{
  "max_docs": 3,
  "source": {
    "index": "my_index_name",
    "query": {
      "bool": {
        "must": [
          {
            "match": {
              "host.hostname": "value_1"
            }
          },
          {
            "match": {
              "message": "value_a"
            }
          }
        ]
      }
    }
  },
  "dest": {
    "index": "new_test"
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文