我正在使用elastic4s在ElasticSearch中制作索引。我的代码如下:
var seqBulkDef = SeqBulkCompatibleDefinition
seqBulkDef=seqBulkDef:+request(sha256, parentId, indexMap, ES_INDEX, ES_INDEX_TYPE)
val resp = client.execute (bulk (seqBulkDef)).await(duration)
def request(sha: String, parentId: String, indexMap: Map, index: String, indexType: String): BulkCompatibleDefinition = {
update(sha) in index / indexType docAsUpsert indexMap parent parentId
}
但它不适用于parentId
。我应该如何修改语法。
答案 0 :(得分:0)
您需要先添加mapping以建立关系,并指定哪种文档类型应该是子类型的父级。
在scala4s中你需要做这样的事情:
client.execute {
put mapping "places" / "city" parent ("country")
}
然后你可以打电话
client.execute {
update("5") in "places" / "cities" docAsUpsert Map("name" -> "São Paulo") parent "2"
}
答案 1 :(得分:-1)
update(id).in("places/city").docAsUpsert(write(json)) refresh (RefreshPolicy.IMMEDIATE)