Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Documents Function and fixed issued:#769 #772

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading