【发布时间】:2020-09-06 17:52:41
【问题描述】:
我希望模拟一种状态,即我在索引中有一个特定的 _id 字段。
假设我想在我的示例中从 index1 获取完全相同的日志并将其索引到 index2。
像这样:
这是我的index1
{
_index: "index-number-one",
_type: "doc",
_id: "S0meSpec!f!cID",
_score: 1,
_source: {
message: "message1",
type: "type1",
tags: [
"_bla"],
number: 3
}
}
现在我希望在我的 index2
中使用完全相同的日志{
_index: "index-number-two",
_type: "doc",
_id: "S0meSpec!f!cID",
_score: 1,
_source: {
message: "message1",
type: "type1",
tags: [
"_bla"],
number: 3
}
}
在 Elasticsearch 中找不到可以将文档插入到具有特定 _id 字段的索引的 API...(?)
如果无法执行此操作以使 Elasticsearch 集群不会在 _id 字段中出现重复项,我可以想象这是因为他们希望保留通过文档的 _id 搜索文档的能力 需要唯一的字段,在这种情况下,假设我不介意从 index1 中删除整个文档(可能将其保存为我的代码中的某个变量) ,但最后,我需要 index2 中的文档,将 EXACT _id 作为 index1 曾经拥有.
如果有办法编辑现有的 _id 字段,它也可以解决我的问题。
谁能解释一下如何实现这个目标?
【问题讨论】:
-
有
meta属性,您可以在索引文档时传递该属性。示例:我从 python 中这样做JiraIndex(meta={'id': 'XYKAL1776reLAO'}, jira_num='AQPEO74', ....)
标签: api elasticsearch logging indexing