@@ -161,13 +161,37 @@ String getRawDocuments(String uid, DocumentsQuery param) throws MeilisearchExcep
161161 */
162162 TaskInfo addDocuments (String uid , String document , String primaryKey , String csvDelimiter )
163163 throws MeilisearchException {
164+ return addDocuments (uid , document , primaryKey , csvDelimiter , null );
165+ }
166+
167+ /**
168+ * Adds/Replaces a document at the specified index uid
169+ *
170+ * @param uid Partial index identifier for the document
171+ * @param document String containing the document to add
172+ * @param primaryKey PrimaryKey of the document
173+ * @param csvDelimiter CSV delimiter of the document
174+ * @param customMetadata Custom metadata to attach to the task
175+ * @return Meilisearch's TaskInfo API response
176+ * @throws MeilisearchException if the client request causes an error
177+ */
178+ TaskInfo addDocuments (
179+ String uid ,
180+ String document ,
181+ String primaryKey ,
182+ String csvDelimiter ,
183+ String customMetadata )
184+ throws MeilisearchException {
164185 URLBuilder urlb = documentPath (uid );
165186 if (primaryKey != null ) {
166187 urlb .addParameter ("primaryKey" , primaryKey );
167188 }
168189 if (csvDelimiter != null ) {
169190 urlb .addParameter ("csvDelimiter" , csvDelimiter );
170191 }
192+ if (customMetadata != null ) {
193+ urlb .addParameter ("customMetadata" , customMetadata );
194+ }
171195 return httpClient .post (urlb .getURL (), document , TaskInfo .class );
172196 }
173197
@@ -182,13 +206,37 @@ TaskInfo addDocuments(String uid, String document, String primaryKey, String csv
182206 */
183207 TaskInfo updateDocuments (String uid , String document , String primaryKey , String csvDelimiter )
184208 throws MeilisearchException {
209+ return updateDocuments (uid , document , primaryKey , csvDelimiter , null );
210+ }
211+
212+ /**
213+ * Replaces a document at the specified index uid
214+ *
215+ * @param uid Partial index identifier for the document
216+ * @param document String containing the document to replace the existing document
217+ * @param primaryKey PrimaryKey of the document
218+ * @param csvDelimiter CSV delimiter of the document
219+ * @param customMetadata Custom metadata to attach to the task
220+ * @return Meilisearch's TaskInfo API response
221+ * @throws MeilisearchException if the client request causes an error
222+ */
223+ TaskInfo updateDocuments (
224+ String uid ,
225+ String document ,
226+ String primaryKey ,
227+ String csvDelimiter ,
228+ String customMetadata )
229+ throws MeilisearchException {
185230 URLBuilder urlb = documentPath (uid );
186231 if (primaryKey != null ) {
187232 urlb .addParameter ("primaryKey" , primaryKey );
188233 }
189234 if (csvDelimiter != null ) {
190235 urlb .addParameter ("csvDelimiter" , csvDelimiter );
191236 }
237+ if (customMetadata != null ) {
238+ urlb .addParameter ("customMetadata" , customMetadata );
239+ }
192240 return httpClient .put (urlb .getURL (), document , TaskInfo .class );
193241 }
194242
@@ -201,7 +249,25 @@ TaskInfo updateDocuments(String uid, String document, String primaryKey, String
201249 * @throws MeilisearchException if the client request causes an error
202250 */
203251 TaskInfo deleteDocument (String uid , String identifier ) throws MeilisearchException {
204- return httpClient .<TaskInfo >delete (documentPath (uid , identifier ).getURL (), TaskInfo .class );
252+ return deleteDocument (uid , identifier , null );
253+ }
254+
255+ /**
256+ * Deletes the document from the specified index uid with the specified identifier
257+ *
258+ * @param uid Partial index identifier for the requested document
259+ * @param identifier ID of the document
260+ * @param customMetadata Custom metadata to attach to the task
261+ * @return Meilisearch's TaskInfo API response
262+ * @throws MeilisearchException if the client request causes an error
263+ */
264+ TaskInfo deleteDocument (String uid , String identifier , String customMetadata )
265+ throws MeilisearchException {
266+ URLBuilder urlb = documentPath (uid , identifier );
267+ if (customMetadata != null ) {
268+ urlb .addParameter ("customMetadata" , customMetadata );
269+ }
270+ return httpClient .<TaskInfo >delete (urlb .getURL (), TaskInfo .class );
205271 }
206272
207273 /**
@@ -213,7 +279,24 @@ TaskInfo deleteDocument(String uid, String identifier) throws MeilisearchExcepti
213279 * @throws MeilisearchException if the client request causes an error
214280 */
215281 TaskInfo deleteDocuments (String uid , List <String > identifiers ) throws MeilisearchException {
282+ return deleteDocuments (uid , identifiers , null );
283+ }
284+
285+ /**
286+ * Deletes the documents at the specified index uid with the specified identifiers
287+ *
288+ * @param uid Partial index identifier for the requested documents
289+ * @param identifiers ID of documents to delete
290+ * @param customMetadata Custom metadata to attach to the task
291+ * @return Meilisearch's TaskInfo API response
292+ * @throws MeilisearchException if the client request causes an error
293+ */
294+ TaskInfo deleteDocuments (String uid , List <String > identifiers , String customMetadata )
295+ throws MeilisearchException {
216296 URLBuilder urlb = documentPath (uid ).addSubroute ("delete-batch" );
297+ if (customMetadata != null ) {
298+ urlb .addParameter ("customMetadata" , customMetadata );
299+ }
217300 return httpClient .post (urlb .getURL (), identifiers , TaskInfo .class );
218301 }
219302
@@ -226,13 +309,30 @@ TaskInfo deleteDocuments(String uid, List<String> identifiers) throws Meilisearc
226309 * @throws MeilisearchException if the client request causes an error
227310 */
228311 TaskInfo deleteDocumentsByFilter (String uid , String filter ) throws MeilisearchException {
312+ return deleteDocumentsByFilter (uid , filter , null );
313+ }
314+
315+ /**
316+ * Deletes the documents matching the given filter
317+ *
318+ * @param uid Partial index identifier for the requested documents
319+ * @param filter filter to match the documents on
320+ * @param customMetadata Custom metadata to attach to the task
321+ * @return Meilisearch's TaskInfo API response
322+ * @throws MeilisearchException if the client request causes an error
323+ */
324+ TaskInfo deleteDocumentsByFilter (String uid , String filter , String customMetadata )
325+ throws MeilisearchException {
229326 if (filter == null || filter .isEmpty ()) {
230327 throw new MeilisearchException (
231328 "Null or blank filter not allowed while deleting documents" );
232329 }
233330 HashMap <String , String > filterMap = new HashMap <>();
234331 filterMap .put ("filter" , filter );
235332 URLBuilder urlb = documentPath (uid ).addSubroute ("delete" );
333+ if (customMetadata != null ) {
334+ urlb .addParameter ("customMetadata" , customMetadata );
335+ }
236336 return httpClient .post (urlb .getURL (), filterMap , TaskInfo .class );
237337 }
238338
@@ -244,7 +344,23 @@ TaskInfo deleteDocumentsByFilter(String uid, String filter) throws MeilisearchEx
244344 * @throws MeilisearchException if the client request causes an error
245345 */
246346 TaskInfo deleteAllDocuments (String uid ) throws MeilisearchException {
247- return httpClient .<TaskInfo >delete (documentPath (uid ).getURL (), TaskInfo .class );
347+ return deleteAllDocuments (uid , null );
348+ }
349+
350+ /**
351+ * Deletes all documents at the specified index uid
352+ *
353+ * @param uid Partial index identifier for the requested documents
354+ * @param customMetadata Custom metadata to attach to the task
355+ * @return Meilisearch's TaskInfo API response
356+ * @throws MeilisearchException if the client request causes an error
357+ */
358+ TaskInfo deleteAllDocuments (String uid , String customMetadata ) throws MeilisearchException {
359+ URLBuilder urlb = documentPath (uid );
360+ if (customMetadata != null ) {
361+ urlb .addParameter ("customMetadata" , customMetadata );
362+ }
363+ return httpClient .<TaskInfo >delete (urlb .getURL (), TaskInfo .class );
248364 }
249365
250366 /** Creates an URLBuilder for the constant route documents. */
0 commit comments