get.asciidoc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. [[get]]
  2. == Get API
  3. The get API allows to get a typed JSON document from the index based on
  4. its id. The following example gets a JSON document from an index called
  5. twitter, under a type called tweet, with id valued 1:
  6. [source,java]
  7. --------------------------------------------------
  8. GetResponse response = client.prepareGet("twitter", "tweet", "1")
  9. .execute()
  10. .actionGet();
  11. --------------------------------------------------
  12. For more information on the index operation, check out the REST
  13. link:{ref}/docs-get.html[get] docs.
  14. === Operation Threading
  15. The get API allows to set the threading model the operation will be
  16. performed when the actual execution of the API is performed on the same
  17. node (the API is executed on a shard that is allocated on the same
  18. server).
  19. The options are to execute the operation on a different thread, or to
  20. execute it on the calling thread (note that the API is still async). By
  21. default, `operationThreaded` is set to `true` which means the operation
  22. is executed on a different thread. Here is an example that sets it to
  23. `false`:
  24. [source,java]
  25. --------------------------------------------------
  26. GetResponse response = client.prepareGet("twitter", "tweet", "1")
  27. .setOperationThreaded(false)
  28. .execute()
  29. .actionGet();
  30. --------------------------------------------------