我想问一下,是否由文档中的某个字段分配唯一字段_id。我知道Rest,它可以通过path实现
{
"tweet": {
"_id": {
"path": "post_id"
}
}
}但是,如果我想用java来实现它,有什么方法可以实现吗?
Map<String, Object> MapA= new HashMap<String, Object>();
MapA=MapProcessor(MapA);
client.prepareIndex("index","type").setSource(MapA).execute().actionGet();我如何修改我的代码来分配地图中的某些字段,使其成为这种类型的_id?
发布于 2014-07-26 03:35:09
只需在索引时提供id,如下所示
Map<String, Object> MapA= new HashMap<String, Object>();
MapA=MapProcessor(MapA);
client.prepareIndex("index","type",MapA.get("post_id")).setSource(MapA).execute().actionGet();如果您不想这样做,那么将其添加为映射。
{
"tweet" : {
"_id" : {
"path" : "post_id"
}
}
}如果将post_id字段添加到elasticsearch中,那么它也将成为"_id“。
https://stackoverflow.com/questions/24965867
复制相似问题