elasticsearch java rest api groovy script update document -




@test public void testrestclient() throws ioexception {     restclient restclient = restclient.builder(new httphost("10.12.31.110", 9200, "http")).build();      map<string, string> param = new hashmap<>();     param.put("script",             "if(ctx._source.student.books==null){ctx._source.student.books=listvalue}else{ctx._source.student.books.add"                     + "(objectvalue)}");      map<string, string> params = new hashmap<>();     map<string, string> objectparam = new hashmap<>();     objectparam.put("name", "http");     objectparam.put("id", "15");     list<map<string, string>> listparam = new arraylist<>();     listparam.add(objectparam);      params.put("listvalue", gson.tojson(listparam));     params.put("objectvalue", gson.tojson(objectparam));     param.put("params", gson.tojson(params));      stringbuilder dbuilder = new stringbuilder();     dbuilder.append("%20-d%20'").append(gson.tojson(param)).append("'");      httpentity entity = new nstringentity(gson.tojson(param), contenttype.application_json);      final response post = restclient.performrequest("post", "/test_oll/ool/733432282/_update" /*+ dbuilder.tostring()*/,             collections.empty_map,entity);      system.out.println(post); } 





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -

python - Django Import by filename is not supported -