通过java api

时间:2016-10-10 19:15:22

标签: java elasticsearch

我正在尝试使用UpdateRequest通过java api更新索引中的值,该{ "took": 2, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 1, "max_score": 0.94064164, "hits": [ { "_index": "ticketdump", "_type": "event", "_id": "AVefK2vFmf0chKzzBkzy", "_score": 0.94064164, "_source": { "clientversion": "123465", "queue": "test,test", "vertical": "test", "troubleshooting": "test", "reason": "test", "status": "test", "ticketversion": "1132465", "apuid": 1, "golive": "2014-07-14", "clientname": "test", "message": "test", "product": "test", "clientid": 1, "createddatetime": "2016-05-03 09:43:48", "area": "test", "developmentfix": "test", "actiontaken": "test", "categoryname": "test", "parentcategory": "test", "problemdef": "test", "ticketid": 1 } } ] } } 接受三个参数。

  • 索引
  • 文档
  • ID

问题 - 我知道我的索引名称是什么,但我不确定应该在文档 id 字段中传递什么值。

示例数据

_source

我试图传递UpdateRequest updateRequest = new UpdateRequest("ticketdump",js.getJSONObject("hits").getJSONArray("hits").getJSONObject(0).getJSONObject("_source").toString(),"1").script(new Script("ctx._source.message = \"bhavik\"")); client.update(updateRequest).get(); 对象,但是文档遗漏了错误。也许我错过了这个概念?

JAVA CODE

function ff(b, o) {
  if (b) {
    return o.x   // IC here
  } else {
    return o.x   // IC here
  }
}

1 个答案:

答案 0 :(得分:3)

实际上,您的UpdateRequest接受3个参数

  1. 索引
  2. 类型
  3. 编号
  4. 通过以下数据,您可以看到:

    1. Index = ticketdump
    2. Type = event
    3. Id = AVefK2vFmf0chKzzBkzy