使用摄入管道分开两个索引

发布于 2025-01-26 16:24:55 字数 419 浏览 2 评论 0原文

我有包含“状态”字段的文档,这可以具有三个值“草案”,“正在进行”或“批准”。我正在尝试通过摄入的管道将此文档传递,如果状态等于“批准”,则应将其添加到B索引中,而默认情况下,它应在索引中索引,而与状态值无关。 对于前 - 1。

{
"id":"123",
"status":"Draft"
}
{
"id":"1234",
"status":"InProgress"
}
{
"id":"12345",
"status":"Approved"
}

1,2,3文件应转到索引,只有文件3才能转到B索引 是否可以通过摄入管道进行操作?

I have documents containing the field "Status", this can have three values "Draft", "In Progress", or "Approved". I am trying to pass this document through a ingest pipeline, and if the status is equal to "Approved" then it should add it in the B index, whereas by default it should index in A index irrespective of status value.
for ex -
1.

{
"id":"123",
"status":"Draft"
}
{
"id":"1234",
"status":"InProgress"
}
{
"id":"12345",
"status":"Approved"
}

1,2,3 document should go to A Index and only document 3 should go to B Index
Is it possible to do it via Ingest Pipeline?

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

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

发布评论

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

评论(1

一笔一画续写前缘 2025-02-02 16:24:55

在您的摄入管道中,您可以很容易地更改_index字段:

{
  "set": {
    "if": "ctx.status == 'Approved'",
    "field": "_index",
    "value": "index-b"
  }
},
{
  "set": {
    "if": "ctx.status != 'Approved'",
    "field": "_index",
    "value": "index-a"
  }
}

不值得,但是,您不能将文档发送到两个不同的索引在同一索引中管道,它是index-aindex-b,但不是两者兼而有之。

但是,可以通过跨越index-aindex-b的别名来查询这两个索引,从而可以轻松解决这一问题。

In your ingest pipeline, you can change the _index field very easily like this:

{
  "set": {
    "if": "ctx.status == 'Approved'",
    "field": "_index",
    "value": "index-b"
  }
},
{
  "set": {
    "if": "ctx.status != 'Approved'",
    "field": "_index",
    "value": "index-a"
  }
}

It is worth nothing, though, that you cannot send a document to two different indexes within the same pipeline, it's either index-a or index-b, but not both.

However, this can easily be solved by querying both indexes through an alias that spans both index-a and index-b

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文