Skip to content

Commit 41dc3d1

Browse files
authored
Updated Documents Function and fixed issued:meilisearch#769
1 parent 9d8616d commit 41dc3d1

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,27 +150,22 @@ String getRawDocuments(String uid, DocumentsQuery param) throws MeilisearchExcep
150150
}
151151

152152
/**
153-
* Adds/Replaces a document at the specified index uid
153+
* Updates documents in the specified index using a function
154154
*
155-
* @param uid Partial index identifier for the document
156-
* @param document String containing the document to add
157-
* @param primaryKey PrimaryKey of the document
158-
* @param csvDelimiter CSV delimiter of the document
155+
* @param uid Partial index identifier for the documents
156+
* @param updateFunction Map containing the function to update documents
159157
* @return Meilisearch's TaskInfo API response
160158
* @throws MeilisearchException if the client request causes an error
161159
*/
162-
TaskInfo addDocuments(String uid, String document, String primaryKey, String csvDelimiter)
163-
throws MeilisearchException {
164-
URLBuilder urlb = documentPath(uid);
165-
if (primaryKey != null) {
166-
urlb.addParameter("primaryKey", primaryKey);
160+
TaskInfo updateDocumentsByFunction(String uid, Map<String, Object> updateFunction) throws MeilisearchException {
161+
if (updateFunction == null || updateFunction.isEmpty()) {
162+
throw new MeilisearchException("Update function cannot be null or empty");
167163
}
168-
if (csvDelimiter != null) {
169-
urlb.addParameter("csvDelimiter", csvDelimiter);
170-
}
171-
return httpClient.post(urlb.getURL(), document, TaskInfo.class);
164+
URLBuilder urlb = documentPath(uid).addSubroute("edit");
165+
return httpClient.post(urlb.getURL(), updateFunction, TaskInfo.class);
172166
}
173167

168+
174169
/**
175170
* Replaces a document at the specified index uid
176171
*

0 commit comments

Comments
 (0)