7
7
import com .auth0 .jwt .algorithms .Algorithm ;
8
8
import com .meilisearch .sdk .exceptions .MeilisearchException ;
9
9
import com .meilisearch .sdk .json .JsonHandler ;
10
+ import com .meilisearch .sdk .model .IndexesQuery ;
10
11
import com .meilisearch .sdk .model .Key ;
11
12
import com .meilisearch .sdk .model .Results ;
12
13
import com .meilisearch .sdk .model .Stats ;
@@ -63,33 +64,46 @@ public TaskInfo createIndex(String uid) throws MeilisearchException {
63
64
* @throws MeilisearchException if an error occurs
64
65
*/
65
66
public TaskInfo createIndex (String uid , String primaryKey ) throws MeilisearchException {
66
- return this .indexesHandler .create (uid , primaryKey );
67
+ return this .indexesHandler .createIndex (uid , primaryKey );
67
68
}
68
69
69
70
/**
70
- * Gets all indexes in the current Meilisearch instance
71
- * https://docs.meilisearch.com/reference/api/indexes.html#list-all-indexes
71
+ * Gets indexes https://docs.meilisearch.com/reference/api/indexes.html#list-all-indexes
72
72
*
73
- * @return Array of indexes in the Meilisearch client
73
+ * @return Results containing a list of indexes from the Meilisearch API
74
74
* @throws MeilisearchException if an error occurs
75
75
*/
76
- public Index [] getIndexes () throws MeilisearchException {
77
- Index [] indexes = jsonHandler . decode ( getRawIndexes (), Index []. class );
78
- for (Index index : indexes ) {
76
+ public Results < Index > getIndexes () throws MeilisearchException {
77
+ Results < Index > indexes = this . indexesHandler . getIndexes ( );
78
+ for (Index index : indexes . getResults () ) {
79
79
index .setConfig (this .config );
80
80
}
81
81
return indexes ;
82
82
}
83
83
84
84
/**
85
- * Gets all indexes in the current Meilisearch instance
86
- * https://docs.meilisearch.com/reference/api/indexes.html#list-all-indexes
85
+ * Gets indexes https://docs.meilisearch.com/reference/api/indexes.html#list-all-indexes
87
86
*
88
- * @return Meilisearch API response as String
87
+ * @param params query parameters accepted by the get indexes route
88
+ * @return Results containing a list of indexes from the Meilisearch API
89
+ * @throws MeilisearchException if an error occurs
90
+ */
91
+ public Results <Index > getIndexes (IndexesQuery params ) throws MeilisearchException {
92
+ Results <Index > indexes = this .indexesHandler .getIndexes (params );
93
+ for (Index index : indexes .getResults ()) {
94
+ index .setConfig (this .config );
95
+ }
96
+ return indexes ;
97
+ }
98
+
99
+ /**
100
+ * Gets all indexes https://docs.meilisearch.com/reference/api/indexes.html#list-all-indexes
101
+ *
102
+ * @return List of indexes from the Meilisearch API as String
89
103
* @throws MeilisearchException if an error occurs
90
104
*/
91
105
public String getRawIndexes () throws MeilisearchException {
92
- return this .indexesHandler .getAll ();
106
+ return this .indexesHandler .getRawIndexes ();
93
107
}
94
108
95
109
/**
@@ -98,7 +112,7 @@ public String getRawIndexes() throws MeilisearchException {
98
112
* methods in the Index class.
99
113
*
100
114
* @param uid Unique identifier of the index
101
- * @return Index instance
115
+ * @return Meilisearch API response as Index instance
102
116
* @throws MeilisearchException if an error occurs
103
117
*/
104
118
public Index index (String uid ) throws MeilisearchException {
@@ -113,29 +127,17 @@ public Index index(String uid) throws MeilisearchException {
113
127
* https://docs.meilisearch.com/reference/api/indexes.html#get-one-index
114
128
*
115
129
* @param uid Unique identifier of the index to get
116
- * @return Meilisearch API response
130
+ * @return Meilisearch API response as Index instance
117
131
* @throws MeilisearchException if an error occurs
118
132
*/
119
133
public Index getIndex (String uid ) throws MeilisearchException {
120
- Index index = jsonHandler . decode ( getRawIndex ( uid ), Index . class );
134
+ Index index = this . indexesHandler . getIndex ( uid );
121
135
index .setConfig (this .config );
122
136
return index ;
123
137
}
124
138
125
139
/**
126
- * Gets single index by its unique identifier
127
- * https://docs.meilisearch.com/reference/api/indexes.html#get-one-index
128
- *
129
- * @param uid Unique identifier of the index to get
130
- * @return Meilisearch API response as String
131
- * @throws MeilisearchException if an error occurs
132
- */
133
- public String getRawIndex (String uid ) throws MeilisearchException {
134
- return this .indexesHandler .get (uid );
135
- }
136
-
137
- /**
138
- * Updates the primary key of an index in the Meilisearch instance
140
+ * Updates the primary key of an index
139
141
* https://docs.meilisearch.com/reference/api/indexes.html#update-an-index
140
142
*
141
143
* @param uid Unique identifier of the index to update
@@ -156,7 +158,7 @@ public TaskInfo updateIndex(String uid, String primaryKey) throws MeilisearchExc
156
158
* @throws MeilisearchException if an error occurs
157
159
*/
158
160
public TaskInfo deleteIndex (String uid ) throws MeilisearchException {
159
- return this .indexesHandler .delete (uid );
161
+ return this .indexesHandler .deleteIndex (uid );
160
162
}
161
163
162
164
/**
@@ -220,7 +222,7 @@ public String getVersion() throws MeilisearchException {
220
222
* https://docs.meilisearch.com/reference/api/tasks.html#get-one-task
221
223
*
222
224
* @param uid Identifier of the requested Task
223
- * @return Task Instance
225
+ * @return Meilisearch API response as Task Instance
224
226
* @throws MeilisearchException if an error occurs
225
227
*/
226
228
public Task getTask (int uid ) throws MeilisearchException {
@@ -230,7 +232,7 @@ public Task getTask(int uid) throws MeilisearchException {
230
232
/**
231
233
* Retrieves list of tasks https://docs.meilisearch.com/reference/api/tasks.html#get-tasks
232
234
*
233
- * @return List of tasks in the Meilisearch client
235
+ * @return TasksResults containing a list of tasks from the Meilisearch API
234
236
* @throws MeilisearchException if an error occurs
235
237
*/
236
238
public TasksResults getTasks () throws MeilisearchException {
@@ -241,7 +243,7 @@ public TasksResults getTasks() throws MeilisearchException {
241
243
* Retrieves list of tasks https://docs.meilisearch.com/reference/api/tasks.html#get-tasks
242
244
*
243
245
* @param param accept by the tasks route
244
- * @return List of tasks in the Meilisearch client
246
+ * @return TasksResults containing a list of tasks from the Meilisearch API
245
247
* @throws MeilisearchException if an error occurs
246
248
*/
247
249
public TasksResults getTasks (TasksQuery param ) throws MeilisearchException {
0 commit comments