【问题标题】:Elasticsearch: "unexpected end of script."Elasticsearch:“脚本意外结束。”
【发布时间】:2019-07-16 11:44:49
【问题描述】:

我在 elasticsearch 中有以下文档

{
  "_index" : "artgroup",
  "_type" : "_doc",
  "_id" : "199162315",
  "_version" : 2,
  "_seq_no" : 113,
  "_primary_term" : 4,
  "found" : true,
  "_source" : {
    "uuid" : "199162315",
    "GroupTitle" : "some GroupTitle",
    "GroupDetails" : "its an Updated artwork",
    "isNew" : true,
    "UserList" : [
      "1",
      "2",
      "3",
      "4"
    ]
  }
}

我正在尝试更新字段GroupTitle 这是我正在尝试做的事情

val updateRequest = new UpdateRequest(ARTGROUP_INDEX_NAME, artGroupUuid)
val fieldName = new Script(ScriptType.INLINE, "painless", "ctx._source.GroupTitle=", singletonMap("GroupTitle", "some updated groupTittle"))
updateRequest.script(fieldName)
val updateResponse = client.update(updateRequest, RequestOptions.DEFAULT);

但我得到以下异常

Suppressed: org.elasticsearch.client.ResponseException: method [POST], host [http://localhost:9200], URI [/artgroup/_update/199162315?timeout=1m], status line [HTTP/1.1 400 Bad Request]
{"error":{"root_cause":[{"type":"remote_transport_exception","reason":"[sara-Inspiron-7773][192.168.1.2:9300][indices:data/write/update[s]]"}],"type":"illegal_argument_exception","reason":"failed to execute script","caused_by":{"type":"script_exception","reason":"compile error","script_stack":["ctx._source.GroupTitle=","                       ^---- HERE"],"script":"ctx._source.GroupTitle=","lang":"painless","caused_by":{"type":"illegal_argument_exception","reason":"unexpected end of script.","caused_by":{"type":"no_viable_alt_exception","reason":null}}}},"status":400}
        at org.elasticsearch.client.RestClient.convertResponse(RestClient.java:260)
        at org.elasticsearch.client.RestClient.performRequest(RestClient.java:238)
        at org.elasticsearch.client.RestClient.performRequest(RestClient.java:212)
        at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1433)
        ... 17 common frames omitted

我在“使用脚本更新”标题下关注此链接 https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-document-update.html 我在这里缺少什么?

【问题讨论】:

标签: java elasticsearch


【解决方案1】:

这是我解决这个问题的方法

val fieldName = new Script(ScriptType.INLINE, "painless", "ctx._source.GroupTitle=params.GroupTitle", singletonMap("GroupTitle", "blah"))

【讨论】:

    猜你喜欢
    • 2015-04-20
    • 2020-04-14
    • 2023-03-28
    • 2018-04-03
    • 2019-07-31
    • 1970-01-01
    • 2022-11-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多