Skip to content

Commit

Permalink
Updated Documents Function and fixed issued:meilisearch#769
Browse files Browse the repository at this point in the history
  • Loading branch information
Er-Sadiq authored Aug 28, 2024
1 parent 9d8616d commit 41dc3d1
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/main/java/com/meilisearch/sdk/Documents.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,27 +150,22 @@ String getRawDocuments(String uid, DocumentsQuery param) throws MeilisearchExcep
}

/**
* Adds/Replaces a document at the specified index uid
* Updates documents in the specified index using a function
*
* @param uid Partial index identifier for the document
* @param document String containing the document to add
* @param primaryKey PrimaryKey of the document
* @param csvDelimiter CSV delimiter of the document
* @param uid Partial index identifier for the documents
* @param updateFunction Map containing the function to update documents
* @return Meilisearch's TaskInfo API response
* @throws MeilisearchException if the client request causes an error
*/
TaskInfo addDocuments(String uid, String document, String primaryKey, String csvDelimiter)
throws MeilisearchException {
URLBuilder urlb = documentPath(uid);
if (primaryKey != null) {
urlb.addParameter("primaryKey", primaryKey);
TaskInfo updateDocumentsByFunction(String uid, Map<String, Object> updateFunction) throws MeilisearchException {
if (updateFunction == null || updateFunction.isEmpty()) {
throw new MeilisearchException("Update function cannot be null or empty");
}
if (csvDelimiter != null) {
urlb.addParameter("csvDelimiter", csvDelimiter);
}
return httpClient.post(urlb.getURL(), document, TaskInfo.class);
URLBuilder urlb = documentPath(uid).addSubroute("edit");
return httpClient.post(urlb.getURL(), updateFunction, TaskInfo.class);
}


/**
* Replaces a document at the specified index uid
*
Expand Down

0 comments on commit 41dc3d1

Please sign in to comment.