Skip to content

Commit 866e88d

Browse files
authored
Merge pull request #508 from meilisearch/result-rename
Rename Result class to Results
2 parents 0136243 + 9abd107 commit 866e88d

22 files changed

+606
-423
lines changed

src/main/java/com/meilisearch/sdk/Client.java

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
import com.meilisearch.sdk.exceptions.MeilisearchException;
99
import com.meilisearch.sdk.json.JsonHandler;
1010
import com.meilisearch.sdk.model.Key;
11-
import com.meilisearch.sdk.model.Result;
11+
import com.meilisearch.sdk.model.Results;
1212
import com.meilisearch.sdk.model.Stats;
1313
import com.meilisearch.sdk.model.Task;
14+
import com.meilisearch.sdk.model.TaskInfo;
15+
import com.meilisearch.sdk.model.TasksQuery;
16+
import com.meilisearch.sdk.model.TasksResults;
1417
import java.util.Date;
1518
import java.util.Map;
1619
import java.util.TimeZone;
@@ -43,10 +46,10 @@ public Client(Config config) {
4346
* https://docs.meilisearch.com/reference/api/indexes.html#create-an-index
4447
*
4548
* @param uid Unique identifier for the index to create
46-
* @return Meilisearch API response as Task
49+
* @return Meilisearch API response as TaskInfo
4750
* @throws MeilisearchException if an error occurs
4851
*/
49-
public Task createIndex(String uid) throws MeilisearchException {
52+
public TaskInfo createIndex(String uid) throws MeilisearchException {
5053
return this.createIndex(uid, null);
5154
}
5255

@@ -56,10 +59,10 @@ public Task createIndex(String uid) throws MeilisearchException {
5659
*
5760
* @param uid Unique identifier for the index to create
5861
* @param primaryKey The primary key of the documents in that index
59-
* @return Meilisearch API response as Task
62+
* @return Meilisearch API response as TaskInfo
6063
* @throws MeilisearchException if an error occurs
6164
*/
62-
public Task createIndex(String uid, String primaryKey) throws MeilisearchException {
65+
public TaskInfo createIndex(String uid, String primaryKey) throws MeilisearchException {
6366
return this.indexesHandler.create(uid, primaryKey);
6467
}
6568

@@ -137,10 +140,10 @@ public String getRawIndex(String uid) throws MeilisearchException {
137140
*
138141
* @param uid Unique identifier of the index to update
139142
* @param primaryKey Primary key of the documents in the index
140-
* @return Meilisearch API response as Task
143+
* @return Meilisearch API response as TaskInfo
141144
* @throws MeilisearchException if an error occurs
142145
*/
143-
public Task updateIndex(String uid, String primaryKey) throws MeilisearchException {
146+
public TaskInfo updateIndex(String uid, String primaryKey) throws MeilisearchException {
144147
return this.indexesHandler.updatePrimaryKey(uid, primaryKey);
145148
}
146149

@@ -149,10 +152,10 @@ public Task updateIndex(String uid, String primaryKey) throws MeilisearchExcepti
149152
* https://docs.meilisearch.com/reference/api/indexes.html#delete-one-index
150153
*
151154
* @param uid Unique identifier of the index to delete
152-
* @return Meilisearch API response as Task
155+
* @return Meilisearch API response as TaskInfo
153156
* @throws MeilisearchException if an error occurs
154157
*/
155-
public Task deleteIndex(String uid) throws MeilisearchException {
158+
public TaskInfo deleteIndex(String uid) throws MeilisearchException {
156159
return this.indexesHandler.delete(uid);
157160
}
158161

@@ -240,10 +243,21 @@ public Task getTask(int uid) throws MeilisearchException {
240243
* @return List of tasks in the Meilisearch client
241244
* @throws MeilisearchException if an error occurs
242245
*/
243-
public Result<Task> getTasks() throws MeilisearchException {
246+
public TasksResults getTasks() throws MeilisearchException {
244247
return this.tasksHandler.getTasks();
245248
}
246249

250+
/**
251+
* Retrieves list of tasks https://docs.meilisearch.com/reference/api/tasks.html#get-tasks
252+
*
253+
* @param param accept by the tasks route
254+
* @return List of tasks in the Meilisearch client
255+
* @throws MeilisearchException if an error occurs
256+
*/
257+
public TasksResults getTasks(TasksQuery param) throws MeilisearchException {
258+
return this.tasksHandler.getTasks(param);
259+
}
260+
247261
/**
248262
* Waits for a task to be processed
249263
*
@@ -272,7 +286,7 @@ public Key getKey(String uid) throws MeilisearchException {
272286
* @return List of keys in the Meilisearch client
273287
* @throws MeilisearchException if an error occurs
274288
*/
275-
public Result<Key> getKeys() throws MeilisearchException {
289+
public Results<Key> getKeys() throws MeilisearchException {
276290
return this.keysHandler.getKeys();
277291
}
278292

src/main/java/com/meilisearch/sdk/Documents.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import static java.util.Collections.singletonList;
44

55
import com.meilisearch.sdk.exceptions.MeilisearchException;
6-
import com.meilisearch.sdk.model.Task;
6+
import com.meilisearch.sdk.model.TaskInfo;
77
import java.util.List;
88

99
/**
@@ -106,15 +106,16 @@ String getDocuments(String uid, int limit, int offset, List<String> attributesTo
106106
* @param uid Partial index identifier for the document
107107
* @param document String containing the document to add
108108
* @param primaryKey PrimaryKey of the document
109-
* @return Meilisearch's Task API response
109+
* @return Meilisearch's TaskInfo API response
110110
* @throws MeilisearchException if the client request causes an error
111111
*/
112-
Task addDocuments(String uid, String document, String primaryKey) throws MeilisearchException {
112+
TaskInfo addDocuments(String uid, String document, String primaryKey)
113+
throws MeilisearchException {
113114
String urlQuery = "/indexes/" + uid + "/documents";
114115
if (primaryKey != null) {
115116
urlQuery += "?primaryKey=" + primaryKey;
116117
}
117-
return httpClient.post(urlQuery, document, Task.class);
118+
return httpClient.post(urlQuery, document, TaskInfo.class);
118119
}
119120

120121
/**
@@ -123,53 +124,53 @@ Task addDocuments(String uid, String document, String primaryKey) throws Meilise
123124
* @param uid Partial index identifier for the document
124125
* @param document String containing the document to replace the existing document
125126
* @param primaryKey PrimaryKey of the document
126-
* @return Meilisearch's Task API response
127+
* @return Meilisearch's TaskInfo API response
127128
* @throws MeilisearchException if the client request causes an error
128129
*/
129-
Task updateDocuments(String uid, String document, String primaryKey)
130+
TaskInfo updateDocuments(String uid, String document, String primaryKey)
130131
throws MeilisearchException {
131132
String urlPath = "/indexes/" + uid + "/documents";
132133
if (primaryKey != null) {
133134
urlPath += "?primaryKey=" + primaryKey;
134135
}
135-
return httpClient.put(urlPath, document, Task.class);
136+
return httpClient.put(urlPath, document, TaskInfo.class);
136137
}
137138

138139
/**
139140
* Deletes the document at the specified index uid with the specified identifier
140141
*
141142
* @param uid Partial index identifier for the requested document
142143
* @param identifier ID of the document
143-
* @return Meilisearch's Task API response
144+
* @return Meilisearch's TaskInfo API response
144145
* @throws MeilisearchException if the client request causes an error
145146
*/
146-
Task deleteDocument(String uid, String identifier) throws MeilisearchException {
147+
TaskInfo deleteDocument(String uid, String identifier) throws MeilisearchException {
147148
String urlPath = "/indexes/" + uid + "/documents/" + identifier;
148-
return httpClient.delete(urlPath, Task.class);
149+
return httpClient.delete(urlPath, TaskInfo.class);
149150
}
150151

151152
/**
152153
* Deletes the documents at the specified index uid with the specified identifiers
153154
*
154155
* @param uid Partial index identifier for the requested documents
155156
* @param identifiers ID of documents to delete
156-
* @return Meilisearch's Task API response
157+
* @return Meilisearch's TaskInfo API response
157158
* @throws MeilisearchException if the client request causes an error
158159
*/
159-
Task deleteDocuments(String uid, List<String> identifiers) throws MeilisearchException {
160+
TaskInfo deleteDocuments(String uid, List<String> identifiers) throws MeilisearchException {
160161
String urlPath = "/indexes/" + uid + "/documents/" + "delete-batch";
161-
return httpClient.post(urlPath, identifiers, Task.class);
162+
return httpClient.post(urlPath, identifiers, TaskInfo.class);
162163
}
163164

164165
/**
165166
* Deletes all documents at the specified index uid
166167
*
167168
* @param uid Partial index identifier for the requested documents
168-
* @return Meilisearch's Task API response
169+
* @return Meilisearch's TaskInfo API response
169170
* @throws MeilisearchException if the client request causes an error
170171
*/
171-
Task deleteAllDocuments(String uid) throws MeilisearchException {
172+
TaskInfo deleteAllDocuments(String uid) throws MeilisearchException {
172173
String urlPath = "/indexes/" + uid + "/documents";
173-
return httpClient.delete(urlPath, Task.class);
174+
return httpClient.delete(urlPath, TaskInfo.class);
174175
}
175176
}

0 commit comments

Comments
 (0)