1- [[java-rest-high-document-index]]
1+ --
2+ :api: index
3+ :request: IndexRequest
4+ :response: IndexResponse
5+ --
6+
7+ [id="{upid}-{api}"]
28=== Index API
39
4- [[java-rest-high-document-index- request] ]
10+ [id="{upid}-{api}- request" ]
511==== Index Request
612
7- An `IndexRequest` requires the following arguments:
13+ An +{request}+ requires the following arguments:
814
915["source","java",subs="attributes,callouts,macros"]
1016--------------------------------------------------
11- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-string]
17+ include-tagged::{doc-tests-file}[{api} -request-string]
1218--------------------------------------------------
1319<1> Index
1420<2> Type
@@ -21,21 +27,21 @@ The document source can be provided in different ways in addition to the
2127
2228["source","java",subs="attributes,callouts,macros"]
2329--------------------------------------------------
24- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-map]
30+ include-tagged::{doc-tests-file}[{api} -request-map]
2531--------------------------------------------------
2632<1> Document source provided as a `Map` which gets automatically converted
2733to JSON format
2834
2935["source","java",subs="attributes,callouts,macros"]
3036--------------------------------------------------
31- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-xcontent]
37+ include-tagged::{doc-tests-file}[{api} -request-xcontent]
3238--------------------------------------------------
3339<1> Document source provided as an `XContentBuilder` object, the Elasticsearch
3440built-in helpers to generate JSON content
3541
3642["source","java",subs="attributes,callouts,macros"]
3743--------------------------------------------------
38- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-shortcut]
44+ include-tagged::{doc-tests-file}[{api} -request-shortcut]
3945--------------------------------------------------
4046<1> Document source provided as `Object` key-pairs, which gets converted to
4147JSON format
@@ -45,95 +51,60 @@ The following arguments can optionally be provided:
4551
4652["source","java",subs="attributes,callouts,macros"]
4753--------------------------------------------------
48- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-routing]
54+ include-tagged::{doc-tests-file}[{api} -request-routing]
4955--------------------------------------------------
5056<1> Routing value
5157
5258["source","java",subs="attributes,callouts,macros"]
5359--------------------------------------------------
54- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-timeout]
60+ include-tagged::{doc-tests-file}[{api} -request-timeout]
5561--------------------------------------------------
5662<1> Timeout to wait for primary shard to become available as a `TimeValue`
5763<2> Timeout to wait for primary shard to become available as a `String`
5864
5965["source","java",subs="attributes,callouts,macros"]
6066--------------------------------------------------
61- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-refresh]
67+ include-tagged::{doc-tests-file}[{api} -request-refresh]
6268--------------------------------------------------
6369<1> Refresh policy as a `WriteRequest.RefreshPolicy` instance
6470<2> Refresh policy as a `String`
6571
6672["source","java",subs="attributes,callouts,macros"]
6773--------------------------------------------------
68- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-version]
74+ include-tagged::{doc-tests-file}[{api} -request-version]
6975--------------------------------------------------
7076<1> Version
7177
7278["source","java",subs="attributes,callouts,macros"]
7379--------------------------------------------------
74- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-version-type]
80+ include-tagged::{doc-tests-file}[{api} -request-version-type]
7581--------------------------------------------------
7682<1> Version type
7783
7884["source","java",subs="attributes,callouts,macros"]
7985--------------------------------------------------
80- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-op-type]
86+ include-tagged::{doc-tests-file}[{api} -request-op-type]
8187--------------------------------------------------
8288<1> Operation type provided as an `DocWriteRequest.OpType` value
8389<2> Operation type provided as a `String`: can be `create` or `update` (default)
8490
8591["source","java",subs="attributes,callouts,macros"]
8692--------------------------------------------------
87- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-pipeline]
93+ include-tagged::{doc-tests-file}[{api} -request-pipeline]
8894--------------------------------------------------
8995<1> The name of the ingest pipeline to be executed before indexing the document
9096
91- [[java-rest-high-document-index-sync]]
92- ==== Synchronous Execution
93-
94- ["source","java",subs="attributes,callouts,macros"]
95- --------------------------------------------------
96- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index-execute]
97- --------------------------------------------------
98-
99- [[java-rest-high-document-index-async]]
100- ==== Asynchronous Execution
101-
102- The asynchronous execution of an index request requires both the `IndexRequest`
103- instance and an `ActionListener` instance to be passed to the asynchronous
104- method:
105-
106- ["source","java",subs="attributes,callouts,macros"]
107- --------------------------------------------------
108- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index-execute-async]
109- --------------------------------------------------
110- <1> The `IndexRequest` to execute and the `ActionListener` to use when
111- the execution completes
112-
113- The asynchronous method does not block and returns immediately. Once it is
114- completed the `ActionListener` is called back using the `onResponse` method
115- if the execution successfully completed or using the `onFailure` method if
116- it failed.
117-
118- A typical listener for `IndexResponse` looks like:
119-
120- ["source","java",subs="attributes,callouts,macros"]
121- --------------------------------------------------
122- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index-execute-listener]
123- --------------------------------------------------
124- <1> Called when the execution is successfully completed. The response is
125- provided as an argument
126- <2> Called in case of failure. The raised exception is provided as an argument
97+ include::../execution.asciidoc[]
12798
128- [[java-rest-high-document-index- response] ]
99+ [id="{upid}-{api}- response" ]
129100==== Index Response
130101
131- The returned `IndexResponse` allows to retrieve information about the executed
102+ The returned +{response}+ allows to retrieve information about the executed
132103 operation as follows:
133104
134105["source","java",subs="attributes,callouts,macros"]
135106--------------------------------------------------
136- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -response]
107+ include-tagged::{doc-tests-file}[{api} -response]
137108--------------------------------------------------
138109<1> Handle (if needed) the case where the document was created for the first
139110time
@@ -148,7 +119,7 @@ be thrown:
148119
149120["source","java",subs="attributes,callouts,macros"]
150121--------------------------------------------------
151- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -conflict]
122+ include-tagged::{doc-tests-file}[{api} -conflict]
152123--------------------------------------------------
153124<1> The raised exception indicates that a version conflict error was returned
154125
@@ -157,6 +128,6 @@ same index, type and id already existed:
157128
158129["source","java",subs="attributes,callouts,macros"]
159130--------------------------------------------------
160- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -optype]
131+ include-tagged::{doc-tests-file}[{api} -optype]
161132--------------------------------------------------
162133<1> The raised exception indicates that a version conflict error was returned
0 commit comments