2017-08-29 46 views
0

如何使用addScriptParam同時使用的Java API在elasticsearch更新文件,我剛剛升級到較新的版本Elasticsearch 5.2版本1.6.0我得到下面的代碼如何在更新elasticsearch 5.2中的文檔時使用addScriptParam?

for (n<-0 to followList.size-1) { 
      var newObject:java.util.Map[String,Object] = Maps.newHashMap(); 
      var follow=followList.get(n) 
      var followuuid=follow.getFollowID 
      var uuidType=follow.getClassType().toString() 
      newObject.put("FollowingItemUuid",followuuid) 
      newObject.put("FollowingItemUuidType",uuidType) 
      bulkRequest.add(client.prepareUpdate("testdb", ARTISTUSER_COLLECTION_NAME, artistUser.uuid) 
      .addScriptParam("newObject", newObject) 
      .setScript(new Script(script.ScriptType.INLINE,"ctx._source.FollowingItems += newObject",null,null))) 

     } 

日食給錯誤

編譯時間
value addScriptParam is not a member of org.elasticsearch.action.update.UpdateRequestBuilder possible cause: maybe a semicolon is missing before `value 
addScriptParam'? 

我已經在網上進行搜索,但沒有得到一個解決方案,我知道ES較新的版本中更新的API改變了很多東西,但我沒有發現任何例如對於addScriptParam如何ES 5.2的Java API使用addScriptParam

回答

0

根據documentation,請使用腳本(腳本)方法。

@Deprecated 
public UpdateRequest addScriptParam(java.lang.String name, java.lang.Object value) 
Deprecated. Use script(Script) instead 
Add a script parameter. 
+0

我已經使用腳本在這裏.setScript(新的腳本(script.ScriptType.INLINE, 「ctx._source.FollowingItems + = NEWOBJECT」,NULL,NULL))),但我不知道如何添加PARAMS在其中 – swaheed

+0

你可以請你更新你原來的帖子與你嘗試過的setScript(...)調用? –

相關問題