1
- [[java-rest-high-document-index]]
1
+ --
2
+ :api: index
3
+ :request: IndexRequest
4
+ :response: IndexResponse
5
+ --
6
+
7
+ [id="{upid}-{api}"]
2
8
=== Index API
3
9
4
- [[java-rest-high-document-index- request] ]
10
+ [id="{upid}-{api}- request" ]
5
11
==== Index Request
6
12
7
- An `IndexRequest` requires the following arguments:
13
+ An +{request}+ requires the following arguments:
8
14
9
15
["source","java",subs="attributes,callouts,macros"]
10
16
--------------------------------------------------
11
- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-string]
17
+ include-tagged::{doc-tests-file}[{api} -request-string]
12
18
--------------------------------------------------
13
19
<1> Index
14
20
<2> Type
@@ -21,21 +27,21 @@ The document source can be provided in different ways in addition to the
21
27
22
28
["source","java",subs="attributes,callouts,macros"]
23
29
--------------------------------------------------
24
- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-map]
30
+ include-tagged::{doc-tests-file}[{api} -request-map]
25
31
--------------------------------------------------
26
32
<1> Document source provided as a `Map` which gets automatically converted
27
33
to JSON format
28
34
29
35
["source","java",subs="attributes,callouts,macros"]
30
36
--------------------------------------------------
31
- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-xcontent]
37
+ include-tagged::{doc-tests-file}[{api} -request-xcontent]
32
38
--------------------------------------------------
33
39
<1> Document source provided as an `XContentBuilder` object, the Elasticsearch
34
40
built-in helpers to generate JSON content
35
41
36
42
["source","java",subs="attributes,callouts,macros"]
37
43
--------------------------------------------------
38
- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-shortcut]
44
+ include-tagged::{doc-tests-file}[{api} -request-shortcut]
39
45
--------------------------------------------------
40
46
<1> Document source provided as `Object` key-pairs, which gets converted to
41
47
JSON format
@@ -45,95 +51,60 @@ The following arguments can optionally be provided:
45
51
46
52
["source","java",subs="attributes,callouts,macros"]
47
53
--------------------------------------------------
48
- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-routing]
54
+ include-tagged::{doc-tests-file}[{api} -request-routing]
49
55
--------------------------------------------------
50
56
<1> Routing value
51
57
52
58
["source","java",subs="attributes,callouts,macros"]
53
59
--------------------------------------------------
54
- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-timeout]
60
+ include-tagged::{doc-tests-file}[{api} -request-timeout]
55
61
--------------------------------------------------
56
62
<1> Timeout to wait for primary shard to become available as a `TimeValue`
57
63
<2> Timeout to wait for primary shard to become available as a `String`
58
64
59
65
["source","java",subs="attributes,callouts,macros"]
60
66
--------------------------------------------------
61
- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-refresh]
67
+ include-tagged::{doc-tests-file}[{api} -request-refresh]
62
68
--------------------------------------------------
63
69
<1> Refresh policy as a `WriteRequest.RefreshPolicy` instance
64
70
<2> Refresh policy as a `String`
65
71
66
72
["source","java",subs="attributes,callouts,macros"]
67
73
--------------------------------------------------
68
- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-version]
74
+ include-tagged::{doc-tests-file}[{api} -request-version]
69
75
--------------------------------------------------
70
76
<1> Version
71
77
72
78
["source","java",subs="attributes,callouts,macros"]
73
79
--------------------------------------------------
74
- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-version-type]
80
+ include-tagged::{doc-tests-file}[{api} -request-version-type]
75
81
--------------------------------------------------
76
82
<1> Version type
77
83
78
84
["source","java",subs="attributes,callouts,macros"]
79
85
--------------------------------------------------
80
- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-op-type]
86
+ include-tagged::{doc-tests-file}[{api} -request-op-type]
81
87
--------------------------------------------------
82
88
<1> Operation type provided as an `DocWriteRequest.OpType` value
83
89
<2> Operation type provided as a `String`: can be `create` or `update` (default)
84
90
85
91
["source","java",subs="attributes,callouts,macros"]
86
92
--------------------------------------------------
87
- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -request-pipeline]
93
+ include-tagged::{doc-tests-file}[{api} -request-pipeline]
88
94
--------------------------------------------------
89
95
<1> The name of the ingest pipeline to be executed before indexing the document
90
96
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[]
127
98
128
- [[java-rest-high-document-index- response] ]
99
+ [id="{upid}-{api}- response" ]
129
100
==== Index Response
130
101
131
- The returned `IndexResponse` allows to retrieve information about the executed
102
+ The returned +{response}+ allows to retrieve information about the executed
132
103
operation as follows:
133
104
134
105
["source","java",subs="attributes,callouts,macros"]
135
106
--------------------------------------------------
136
- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -response]
107
+ include-tagged::{doc-tests-file}[{api} -response]
137
108
--------------------------------------------------
138
109
<1> Handle (if needed) the case where the document was created for the first
139
110
time
@@ -148,7 +119,7 @@ be thrown:
148
119
149
120
["source","java",subs="attributes,callouts,macros"]
150
121
--------------------------------------------------
151
- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -conflict]
122
+ include-tagged::{doc-tests-file}[{api} -conflict]
152
123
--------------------------------------------------
153
124
<1> The raised exception indicates that a version conflict error was returned
154
125
@@ -157,6 +128,6 @@ same index, type and id already existed:
157
128
158
129
["source","java",subs="attributes,callouts,macros"]
159
130
--------------------------------------------------
160
- include-tagged::{doc-tests}/CRUDDocumentationIT.java[index -optype]
131
+ include-tagged::{doc-tests-file}[{api} -optype]
161
132
--------------------------------------------------
162
133
<1> The raised exception indicates that a version conflict error was returned
0 commit comments