2013-08-28 19:24:34 -04:00
|
|
|
[[get]]
|
|
|
|
== Get API
|
|
|
|
|
|
|
|
The get API allows to get a typed JSON document from the index based on
|
|
|
|
its id. The following example gets a JSON document from an index called
|
|
|
|
twitter, under a type called tweet, with id valued 1:
|
|
|
|
|
|
|
|
[source,java]
|
|
|
|
--------------------------------------------------
|
|
|
|
GetResponse response = client.prepareGet("twitter", "tweet", "1")
|
|
|
|
.execute()
|
|
|
|
.actionGet();
|
|
|
|
--------------------------------------------------
|
|
|
|
|
2013-09-30 07:26:14 -04:00
|
|
|
For more information on the get operation, check out the REST
|
2013-09-03 10:15:28 -04:00
|
|
|
{ref}/docs-get.html[get] docs.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2013-09-03 10:15:07 -04:00
|
|
|
|
2013-08-28 19:24:34 -04:00
|
|
|
=== Operation Threading
|
|
|
|
|
|
|
|
The get API allows to set the threading model the operation will be
|
|
|
|
performed when the actual execution of the API is performed on the same
|
|
|
|
node (the API is executed on a shard that is allocated on the same
|
|
|
|
server).
|
|
|
|
|
|
|
|
The options are to execute the operation on a different thread, or to
|
|
|
|
execute it on the calling thread (note that the API is still async). By
|
|
|
|
default, `operationThreaded` is set to `true` which means the operation
|
|
|
|
is executed on a different thread. Here is an example that sets it to
|
|
|
|
`false`:
|
|
|
|
|
|
|
|
[source,java]
|
|
|
|
--------------------------------------------------
|
|
|
|
GetResponse response = client.prepareGet("twitter", "tweet", "1")
|
|
|
|
.setOperationThreaded(false)
|
|
|
|
.execute()
|
|
|
|
.actionGet();
|
|
|
|
--------------------------------------------------
|