Skip to content

Commit 14f2445

Browse files
committed
javadoc client
1 parent c92b342 commit 14f2445

15 files changed

+697
-33
lines changed

.idea/libraries/jgroups.xml

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/projectCodeStyle.xml

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/elasticsearch/src/main/java/org/elasticsearch/ElasticSearchException.java

+11-7
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
package org.elasticsearch;
2121

2222
/**
23-
* @author kimchy (Shay Banon) (Shay Banon)
23+
* A base class for all elasticsearch exceptions.
24+
*
25+
* @author kimchy (Shay Banon)
2426
*/
2527
public class ElasticSearchException extends RuntimeException {
2628

2729
/**
28-
* Construct a <code>NestedRuntimeException</code> with the specified detail message.
30+
* Construct a <code>ElasticSearchException</code> with the specified detail message.
2931
*
3032
* @param msg the detail message
3133
*/
@@ -34,7 +36,7 @@ public ElasticSearchException(String msg) {
3436
}
3537

3638
/**
37-
* Construct a <code>NestedRuntimeException</code> with the specified detail message
39+
* Construct a <code>ElasticSearchException</code> with the specified detail message
3840
* and nested exception.
3941
*
4042
* @param msg the detail message
@@ -44,6 +46,12 @@ public ElasticSearchException(String msg, Throwable cause) {
4446
super(msg, cause);
4547
}
4648

49+
/**
50+
* Unwraps the actual cause from the exception for cases when the exception is a
51+
* {@link ElasticSearchWrapperException}.
52+
*
53+
* @see org.elasticsearch.ExceptionsHelper#unwrapCause(Throwable)
54+
*/
4755
public Throwable unwrapCause() {
4856
return ExceptionsHelper.unwrapCause(this);
4957
}
@@ -68,9 +76,6 @@ public String getDetailedMessage() {
6876

6977
/**
7078
* Retrieve the innermost cause of this exception, if any.
71-
*
72-
* @return the innermost exception, or <code>null</code> if none
73-
* @since 2.0
7479
*/
7580
public Throwable getRootCause() {
7681
Throwable rootCause = null;
@@ -89,7 +94,6 @@ public Throwable getRootCause() {
8994
* to the present exception if there is no root cause.
9095
*
9196
* @return the most specific cause (never <code>null</code>)
92-
* @since 2.0.3
9397
*/
9498
public Throwable getMostSpecificCause() {
9599
Throwable rootCause = getRootCause();

modules/elasticsearch/src/main/java/org/elasticsearch/action/index/IndexRequest.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.elasticsearch.action.support.replication.ShardReplicationOperationRequest;
2525
import org.elasticsearch.util.Required;
2626
import org.elasticsearch.util.TimeValue;
27+
import org.elasticsearch.util.json.JsonBuilder;
2728

2829
import java.io.DataInput;
2930
import java.io.DataOutput;
@@ -122,7 +123,7 @@ String id() {
122123
return id;
123124
}
124125

125-
@Required public IndexRequest id(String id) {
126+
public IndexRequest id(String id) {
126127
this.id = id;
127128
return this;
128129
}
@@ -131,7 +132,15 @@ String source() {
131132
return source;
132133
}
133134

134-
public IndexRequest source(String source) {
135+
@Required public IndexRequest source(JsonBuilder jsonBuilder) {
136+
try {
137+
return source(jsonBuilder.string());
138+
} catch (IOException e) {
139+
throw new ElasticSearchIllegalArgumentException("Failed to build json for index request", e);
140+
}
141+
}
142+
143+
@Required public IndexRequest source(String source) {
135144
this.source = source;
136145
return this;
137146
}

modules/elasticsearch/src/main/java/org/elasticsearch/client/AdminClient.java

+9
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,20 @@
2020
package org.elasticsearch.client;
2121

2222
/**
23+
* Administrative actions/operations against the cluster or the indices.
24+
*
2325
* @author kimchy (Shay Banon)
26+
* @see org.elasticsearch.client.Client#admin()
2427
*/
2528
public interface AdminClient {
2629

30+
/**
31+
* A client allowing to perform actions/operations against the cluster.
32+
*/
2733
ClusterAdminClient cluster();
2834

35+
/**
36+
* A client allowing to perform actions/operations against the indices.
37+
*/
2938
IndicesAdminClient indices();
3039
}

modules/elasticsearch/src/main/java/org/elasticsearch/client/Client.java

+178
Original file line numberDiff line numberDiff line change
@@ -36,53 +36,231 @@
3636
import org.elasticsearch.action.search.SearchScrollRequest;
3737

3838
/**
39+
* A client provides a one stop interface for performing actions/operations against the cluster.
40+
*
41+
* <p>All operations performed are asynchronous by nature. There are three flavors for each operation,
42+
* the simplest returns an {@link ActionFuture}, another that also accepts an {@link ActionListener},
43+
* and the last (prefixed with <tt>exec</tt>) which just accepts an {@link ActionListener} without returning
44+
* an {@link ActionFuture}.
45+
*
46+
* <p>A client can either be retrieved from a {@link org.elasticsearch.server.Server} started, or connected remotely
47+
* to one or more nodes using {@link org.elasticsearch.client.transport.TransportClient}.
48+
*
3949
* @author kimchy (Shay Banon)
50+
* @see org.elasticsearch.server.Server#client()
51+
* @see org.elasticsearch.client.transport.TransportClient
4052
*/
4153
public interface Client {
4254

55+
/**
56+
* Closes the client.
57+
*/
4358
void close();
4459

60+
/**
61+
* The admin client that can be used to perform administrative operations.
62+
*/
4563
AdminClient admin();
4664

65+
/**
66+
* Index a JSON source associated with a given index and type.
67+
*
68+
* <p>The id is optional, if it is not provided, one will be generated automatically.
69+
*
70+
* @param request The index request
71+
* @return The result future
72+
* @see Requests#indexRequest(String)
73+
*/
4774
ActionFuture<IndexResponse> index(IndexRequest request);
4875

76+
/**
77+
* Index a JSON source associated with a given index and type.
78+
*
79+
* <p>The id is optional, if it is not provided, one will be generated automatically.
80+
*
81+
* @param request The index request
82+
* @param listener A listener to be notified with a result
83+
* @return The result future
84+
* @see Requests#indexRequest(String)
85+
*/
4986
ActionFuture<IndexResponse> index(IndexRequest request, ActionListener<IndexResponse> listener);
5087

88+
/**
89+
* Index a JSON source associated with a given index and type.
90+
*
91+
* <p>The id is optional, if it is not provided, one will be generated automatically.
92+
*
93+
* @param request The index request
94+
* @param listener A listener to be notified with a result
95+
* @see Requests#indexRequest(String)
96+
*/
5197
void execIndex(IndexRequest request, ActionListener<IndexResponse> listener);
5298

99+
/**
100+
* Deletes a document from the index based on the index, type and id.
101+
*
102+
* @param request The delete request
103+
* @return The result future
104+
* @see Requests#deleteRequest(String)
105+
*/
53106
ActionFuture<DeleteResponse> delete(DeleteRequest request);
54107

108+
/**
109+
* Deletes a document from the index based on the index, type and id.
110+
*
111+
* @param request The delete request
112+
* @param listener A listener to be notified with a result
113+
* @return The result future
114+
* @see Requests#deleteRequest(String)
115+
*/
55116
ActionFuture<DeleteResponse> delete(DeleteRequest request, ActionListener<DeleteResponse> listener);
56117

118+
/**
119+
* Deletes a document from the index based on the index, type and id.
120+
*
121+
* @param request The delete request
122+
* @param listener A listener to be notified with a result
123+
* @see Requests#deleteRequest(String)
124+
*/
57125
void execDelete(DeleteRequest request, ActionListener<DeleteResponse> listener);
58126

127+
/**
128+
* Deletes all documents from one or more indices based on a query.
129+
*
130+
* @param request The delete by query request
131+
* @return The result future
132+
* @see Requests#deleteByQueryRequest(String...)
133+
*/
59134
ActionFuture<DeleteByQueryResponse> deleteByQuery(DeleteByQueryRequest request);
60135

136+
/**
137+
* Deletes all documents from one or more indices based on a query.
138+
*
139+
* @param request The delete by query request
140+
* @param listener A listener to be notified with a result
141+
* @return The result future
142+
* @see Requests#deleteByQueryRequest(String...)
143+
*/
61144
ActionFuture<DeleteByQueryResponse> deleteByQuery(DeleteByQueryRequest request, ActionListener<DeleteByQueryResponse> listener);
62145

146+
/**
147+
* Deletes all documents from one or more indices based on a query.
148+
*
149+
* @param request The delete by query request
150+
* @param listener A listener to be notified with a result
151+
* @see Requests#deleteByQueryRequest(String...)
152+
*/
63153
void execDeleteByQuery(DeleteByQueryRequest request, ActionListener<DeleteByQueryResponse> listener);
64154

155+
/**
156+
* Gets the JSON source that was indexed from an index with a type and id.
157+
*
158+
* @param request The get request
159+
* @return The result future
160+
* @see Requests#getRequest(String)
161+
*/
65162
ActionFuture<GetResponse> get(GetRequest request);
66163

164+
/**
165+
* Gets the JSON source that was indexed from an index with a type and id.
166+
*
167+
* @param request The get request
168+
* @param listener A listener to be notified with a result
169+
* @return The result future
170+
* @see Requests#getRequest(String)
171+
*/
67172
ActionFuture<GetResponse> get(GetRequest request, ActionListener<GetResponse> listener);
68173

174+
/**
175+
* Gets the JSON source that was indexed from an index with a type and id.
176+
*
177+
* @param request The get request
178+
* @param listener A listener to be notified with a result
179+
* @see Requests#getRequest(String)
180+
*/
69181
void execGet(GetRequest request, ActionListener<GetResponse> listener);
70182

183+
/**
184+
* A count of all the documents matching a specific query.
185+
*
186+
* @param request The count request
187+
* @return The result future
188+
* @see Requests#countRequest(String...)
189+
*/
71190
ActionFuture<CountResponse> count(CountRequest request);
72191

192+
/**
193+
* A count of all the documents matching a specific query.
194+
*
195+
* @param request The count request
196+
* @param listener A listener to be notified of the result
197+
* @return The result future
198+
* @see Requests#countRequest(String...)
199+
*/
73200
ActionFuture<CountResponse> count(CountRequest request, ActionListener<CountResponse> listener);
74201

202+
/**
203+
* A count of all the documents matching a specific query.
204+
*
205+
* @param request The count request
206+
* @param listener A listener to be notified of the result
207+
* @see Requests#countRequest(String...)
208+
*/
75209
void execCount(CountRequest request, ActionListener<CountResponse> listener);
76210

211+
/**
212+
* Search across one or more indices and one or more types with a query.
213+
*
214+
* @param request The search request
215+
* @return The result future
216+
* @see Requests#searchRequest(String...)
217+
*/
77218
ActionFuture<SearchResponse> search(SearchRequest request);
78219

220+
/**
221+
* Search across one or more indices and one or more types with a query.
222+
*
223+
* @param request The search request
224+
* @param listener A listener to be notified of the result
225+
* @return The result future
226+
* @see Requests#searchRequest(String...)
227+
*/
79228
ActionFuture<SearchResponse> search(SearchRequest request, ActionListener<SearchResponse> listener);
80229

230+
/**
231+
* Search across one or more indices and one or more types with a query.
232+
*
233+
* @param request The search request
234+
* @param listener A listener to be notified of the result
235+
* @see Requests#searchRequest(String...)
236+
*/
81237
void execSearch(SearchRequest request, ActionListener<SearchResponse> listener);
82238

239+
/**
240+
* A search scroll request to continue searching a previous scrollable search request.
241+
*
242+
* @param request The search scroll request
243+
* @return The result future
244+
* @see Requests#searchScrollRequest(String)
245+
*/
83246
ActionFuture<SearchResponse> searchScroll(SearchScrollRequest request);
84247

248+
/**
249+
* A search scroll request to continue searching a previous scrollable search request.
250+
*
251+
* @param request The search scroll request
252+
* @param listener A listener to be notified of the result
253+
* @return The result future
254+
* @see Requests#searchScrollRequest(String)
255+
*/
85256
ActionFuture<SearchResponse> searchScroll(SearchScrollRequest request, ActionListener<SearchResponse> listener);
86257

258+
/**
259+
* A search scroll request to continue searching a previous scrollable search request.
260+
*
261+
* @param request The search scroll request
262+
* @param listener A listener to be notified of the result
263+
* @see Requests#searchScrollRequest(String)
264+
*/
87265
void execSearchScroll(SearchScrollRequest request, ActionListener<SearchResponse> listener);
88266
}

0 commit comments

Comments
 (0)