diff options
Diffstat (limited to 'docs/java-rest/high-level')
-rw-r--r-- | docs/java-rest/high-level/apis.asciidoc | 2 | ||||
-rw-r--r-- | docs/java-rest/high-level/apis/_index.asciidoc | 8 | ||||
-rw-r--r-- | docs/java-rest/high-level/apis/delete.asciidoc | 6 | ||||
-rw-r--r-- | docs/java-rest/high-level/apis/get.asciidoc | 143 | ||||
-rw-r--r-- | docs/java-rest/high-level/apis/index.asciidoc | 1 |
5 files changed, 152 insertions, 8 deletions
diff --git a/docs/java-rest/high-level/apis.asciidoc b/docs/java-rest/high-level/apis.asciidoc index 7693dd13ce..49fc8c0b54 100644 --- a/docs/java-rest/high-level/apis.asciidoc +++ b/docs/java-rest/high-level/apis.asciidoc @@ -4,7 +4,7 @@ The Java High Level REST Client supports the following APIs: * <<java-rest-high-document-index>> -* Get API +* <<java-rest-high-document-get>> * <<java-rest-high-document-delete>> diff --git a/docs/java-rest/high-level/apis/_index.asciidoc b/docs/java-rest/high-level/apis/_index.asciidoc index 76ce8e46b4..9600f7cad4 100644 --- a/docs/java-rest/high-level/apis/_index.asciidoc +++ b/docs/java-rest/high-level/apis/_index.asciidoc @@ -109,8 +109,8 @@ include-tagged::{doc-tests}/CRUDDocumentationIT.java[index-execute] include-tagged::{doc-tests}/CRUDDocumentationIT.java[index-execute-async] -------------------------------------------------- <1> Called when the execution is successfully completed. The response is -provided as an argument. -<2> Called in case of failure. The raised exception is provided as an argument. +provided as an argument +<2> Called in case of failure. The raised exception is provided as an argument [[java-rest-high-document-index-response]] ==== Index Response @@ -137,7 +137,7 @@ be thrown: -------------------------------------------------- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index-conflict] -------------------------------------------------- -<1> The raised exception indicates that a version conflict error was returned. +<1> The raised exception indicates that a version conflict error was returned Same will happen in case `opType` was set to `create` and a document with same index, type and id already existed: @@ -146,6 +146,6 @@ same index, type and id already existed: -------------------------------------------------- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index-optype] -------------------------------------------------- -<1> The raised exception indicates that a version conflict error was returned. +<1> The raised exception indicates that a version conflict error was returned diff --git a/docs/java-rest/high-level/apis/delete.asciidoc b/docs/java-rest/high-level/apis/delete.asciidoc index 24a085acc3..5b71f6214a 100644 --- a/docs/java-rest/high-level/apis/delete.asciidoc +++ b/docs/java-rest/high-level/apis/delete.asciidoc @@ -71,8 +71,8 @@ include-tagged::{doc-tests}/CRUDDocumentationIT.java[delete-execute] include-tagged::{doc-tests}/CRUDDocumentationIT.java[delete-execute-async] -------------------------------------------------- <1> Called when the execution is successfully completed. The response is -provided as an argument. -<2> Called in case of failure. The raised exception is provided as an argument. +provided as an argument +<2> Called in case of failure. The raised exception is provided as an argument [[java-rest-high-document-delete-response]] ==== Delete Response @@ -104,5 +104,5 @@ be thrown: -------------------------------------------------- include-tagged::{doc-tests}/CRUDDocumentationIT.java[delete-conflict] -------------------------------------------------- -<1> The raised exception indicates that a version conflict error was returned. +<1> The raised exception indicates that a version conflict error was returned diff --git a/docs/java-rest/high-level/apis/get.asciidoc b/docs/java-rest/high-level/apis/get.asciidoc new file mode 100644 index 0000000000..af1d64fa2a --- /dev/null +++ b/docs/java-rest/high-level/apis/get.asciidoc @@ -0,0 +1,143 @@ +[[java-rest-high-document-get]] +=== Get API + +[[java-rest-high-document-get-request]] +==== Get Request + +A `GetRequest` requires the following arguments: + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-request] +-------------------------------------------------- +<1> Index +<2> Type +<3> Document id + +==== Optional arguments +The following arguments can optionally be provided: + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-request-no-source] +-------------------------------------------------- +<1> Disable source retrieval, enabled by default + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-request-source-include] +-------------------------------------------------- +<1> Configure source inclusion for specific fields + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-request-source-exclude] +-------------------------------------------------- +<1> Configure source exclusion for specific fields + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-request-stored] +-------------------------------------------------- +<1> Configure retrieval for specific stored fields (requires fields to be +stored separately in the mappings) +<2> Retrieve the `message` stored field (requires the field to be stored +separately in the mappings) + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-request-routing] +-------------------------------------------------- +<1> Routing value + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-request-parent] +-------------------------------------------------- +<1> Parent value + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-request-preference] +-------------------------------------------------- +<1> Preference value + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-request-realtime] +-------------------------------------------------- +<1> Set realtime flag to `false` (`true` by default) + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-request-refresh] +-------------------------------------------------- +<1> Perform a refresh before retrieving the document (`false` by default) + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-request-version] +-------------------------------------------------- +<1> Version + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-request-version-type] +-------------------------------------------------- +<1> Version type + +[[java-rest-high-document-get-sync]] +==== Synchronous Execution + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-execute] +-------------------------------------------------- + +[[java-rest-high-document-get-async]] +==== Asynchronous Execution + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-execute-async] +-------------------------------------------------- +<1> Called when the execution is successfully completed. The response is +provided as an argument. +<2> Called in case of failure. The raised exception is provided as an argument. + +[[java-rest-high-document-get-response]] +==== Get Response + +The returned `GetResponse` allows to retrieve the requested document along with +its metadata and eventually stored fields. + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-response] +-------------------------------------------------- +<1> Retrieve the document as a `String` +<2> Retrieve the document as a `Map<String, Object>` +<3> Retrieve the document as a `byte[]` +<4> Handle the scenario where the document was not found. Note that although +the returned response has `404` status code, a valid `GetResponse` is +returned rather than an exception thrown. Such response does not hold any +source document and its `isExists` method returns `false`. + +When a get request is performed against an index that does not exist, the +response has `404` status code, an `ElasticsearchException` gets thrown +which needs to be handled as follows: + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-indexnotfound] +-------------------------------------------------- +<1> Handle the exception thrown because the index does not exist + +In case a specific document version has been requested, and the existing +document has a different version number, a version conflict is raised: + +["source","java",subs="attributes,callouts,macros"] +-------------------------------------------------- +include-tagged::{doc-tests}/CRUDDocumentationIT.java[get-conflict] +-------------------------------------------------- +<1> The raised exception indicates that a version conflict error was returned diff --git a/docs/java-rest/high-level/apis/index.asciidoc b/docs/java-rest/high-level/apis/index.asciidoc index 475b18dcf4..935a4ff549 100644 --- a/docs/java-rest/high-level/apis/index.asciidoc +++ b/docs/java-rest/high-level/apis/index.asciidoc @@ -2,6 +2,7 @@ include::_index.asciidoc[] include::update.asciidoc[] +include::get.asciidoc[] include::delete.asciidoc[] include::bulk.asciidoc[] |