java - 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什么我在这里失踪了吗?
解决方案
这是我解决这个问题的方法
val fieldName = new Script(ScriptType.INLINE, "painless", "ctx._source.GroupTitle=params.GroupTitle", singletonMap("GroupTitle", "blah"))
推荐阅读
- microsoft-cognitive - 语音服务 Javascript SDK 响应缓慢
- android - Android Studio app.gradle 错误:程序类型已存在:android.support.v4.app.BackStackRecord$Op
- android - 如何禁用列表视图的滚动视图并随着单元格的增加增加列表视图的高度?
- xml - xpath 的命名空间前缀无效
- python - 如何将列从另一个数据框连接到特定列?
- postgresql - 如何在 postgressql 查询中添加 LIMIT 子句?
- laravel - Laravel 5.7 删除没有到达控制器删除方法(返回404错误页面)
- chatbot - 使用聊天机器人处理用户的换行符或多行响应?
- c# - DataTemplate 的绑定给目标一个不正确/未设置/空值
- python - Python:在不同的窗口中绘制多个图形(相同的数据但具有不同的 X 范围)