在 ElasticSearch 中使用组合字段作为 id 映射 [英] Using a combined field as id mapping in ElasticSearch
问题描述
从这个问题我可以看出可以使用现有字段作为id在弹性搜索中
From this question I can see that it is possible Use existing field as id in elasticsearch
我的问题是,是否可以做类似的事情但连接字段.
My question is, if can do similar thing but concatenating fields.
{
"RecordID": "a06b0000004SWbdAAG",
"SystemModstamp": "01/31/2013T07:46:02.000Z",
"body": "Test Body"
}
然后做类似的事情
{
"your_mapping" : {
"_id" : {
"path" : "RecordID" + "body"
}
}
}
因此 id 是通过连接这些字段自动形成的.
So the id is automatically formed from concatenating those fields.
推荐答案
不,你不能,你只能让 _id 指向文档中的一个字段,如果需要,也可以使用点符号(例如 level1,level2.id
).
No you can't, you can only make the _id point to a field that's within the document, using the dot notation as well if needed (e.g. level1,level2.id
).
我建议在您的文档中有一个包含整个 id 的字段,或者甚至更好地将 id 取出并在 url 中提供它,因为配置路径会导致在不需要时解析文档.
I'd suggest to have a field that contains the whole id in your documents, or even better to take the id out and provide it in the url, as configuring a path causes the document to be parsed when not needed.
这篇关于在 ElasticSearch 中使用组合字段作为 id 映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!