如何在Elasticsearch 7.1中更新文档

时间:2019-06-18 10:59:41

标签: java scala elasticsearch

我正在尝试通过此链接更新ES文档 https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-document-update.html

这是我尝试做的事情

val artgroup = new ArtGroup(uuid= "abc1xyz", groupTitle= "some title", groupDetails= "someDescription")
val request = new UpdateRequest("indexname","abc1xyz")

val groupTitle = new Script(ScriptType.INLINE,null, "ctx._source.GroupTitle = '" + artGroup.getGroupTitle + "'")
    request.script(groupTitle)

val groupDetails = new Script(ScriptType.INLINE,null, "ctx._source.GroupDetails = '" + artGroup.getDetails + "'")
    request.script(groupDetails)

      val updateResponse = client.updateAsync(updateRequest, RequestOptions.DEFAULT, listener)

我正在遵循编译时错误

: not found: value ScriptType
[error]     val groupTitle = new Script(ScriptType.INLINE,null, "ctx._source.GroupTitle = '" + artGroup.getGroupTitle + "'")
[error]                                 ^
[error] /home/sara/git/arteciate-commons/src/main/scala/models/actors/artgroup/escrud/ArtGroupUpdateESActor.scala:212:22: overloaded method constructor Script with alternatives:
[error]   (x$1: org.elasticsearch.common.io.stream.StreamInput)org.elasticsearch.script.Script <and>
[error]   (x$1: org.elasticsearch.script.ScriptType,x$2: String,x$3: String,x$4: java.util.Map[String,String],x$5: java.util.Map[String,Object])org.elasticsearch.script.Script <and>
[error]   (x$1: org.elasticsearch.script.ScriptType,x$2: String,x$3: String,x$4: java.util.Map[String,Object])org.elasticsearch.script.Script <and>
[error]   (x$1: String)org.elasticsearch.script.Script
[error]  cannot be applied to (<error>, Null, String)
[error]     val groupTitle = new Script(ScriptType.INLINE,null, "ctx._source.GroupTitle = '" + artGroup.getGroupTitle + "'")

,与groupDetails字段相同 正确的方法是什么

0 个答案:

没有答案