当前位置:   article > 正文

Elasticsearch 两种更新操作_elasticsearchrepository更新

elasticsearchrepository更新
  1. /**
  2. * 更新
  3. * @throws IOException
  4. * @throws ExecutionException
  5. * @throws InterruptedException
  6. */
  7. @Test
  8. public void update1() throws IOException, ExecutionException, InterruptedException {
  9. UpdateRequest updateRequest = new UpdateRequest();
  10. updateRequest.index("twitter");
  11. updateRequest.type("tweet");
  12. updateRequest.id("AWQrxpiTF3aJ5qXnAM6l");
  13. updateRequest.doc(XContentFactory.jsonBuilder()
  14. .startObject()
  15. .field("age", 8)
  16. .endObject());
  17. client.update(updateRequest).get();
  18. }
  19. /**
  20. * 更新
  21. * @throws IOException
  22. * @throws ExecutionException
  23. * @throws InterruptedException
  24. */
  25. @Test
  26. public void update2() throws IOException {
  27. client.prepareUpdate("twitter", "tweet", "AWQrxpiTF3aJ5qXnAM6l")
  28. .setDoc(XContentFactory.jsonBuilder()
  29. .startObject()
  30. .field("user", "male2")
  31. .endObject())
  32. .get();
  33. }

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/68853
推荐阅读
相关标签
  

闽ICP备14008679号