有没有办法将术语附加到值数组中?
例如,如果我的文档如下所示:
{
"items": ["item1", "item2", "item3"]
}
我想将“item4”和“item5”附加到它。
我必须在 2 个查询中完成吗?一个加载当前值列表,然后更新该列表?还是有更优雅的方式可以让我在一个查询中附加这些项目?
我正在尝试使用这样的 elastic4s 来做到这一点:
client.execute(ElasticDsl.update id id in indexName / documentType script {
script(s"ctx._source.items += tag").params(Map("tag"->"item4"))
})
为了使用上面的代码片段,我需要启用 groovy 脚本,我不知道如何使用多个项目来做到这一点。
任何的想法?