diff --git a/src/main/java/com/meilisearch/sdk/Index.java b/src/main/java/com/meilisearch/sdk/Index.java index ccaf9139b..120e3bd96 100644 --- a/src/main/java/com/meilisearch/sdk/Index.java +++ b/src/main/java/com/meilisearch/sdk/Index.java @@ -114,10 +114,10 @@ public String getDocuments(int limits, int offset, List attributesToRetr * https://docs.meilisearch.com/reference/api/documents.html#add-or-replace-documents * * @param document Document to add in JSON string format - * @return Task Meilisearch API response + * @return TaskInfo Meilisearch API response * @throws MeilisearchException if an error occurs */ - public Task addDocuments(String document) throws MeilisearchException { + public TaskInfo addDocuments(String document) throws MeilisearchException { return this.documents.addDocuments(this.uid, document, null); } @@ -127,10 +127,10 @@ public Task addDocuments(String document) throws MeilisearchException { * * @param document Document to add in JSON string format * @param primaryKey PrimaryKey of the document to add - * @return Task Meilisearch API response + * @return TaskInfo Meilisearch API response * @throws MeilisearchException if an error occurs */ - public Task addDocuments(String document, String primaryKey) throws MeilisearchException { + public TaskInfo addDocuments(String document, String primaryKey) throws MeilisearchException { return this.documents.addDocuments(this.uid, document, primaryKey); } @@ -141,15 +141,15 @@ public Task addDocuments(String document, String primaryKey) throws MeilisearchE * @param batchSize size of the batch of documents * @param document Document to add in JSON string format * @param primaryKey PrimaryKey of the document to add - * @return Task Meilisearch API response + * @return TaskInfo Meilisearch API response * @throws MeilisearchException if an error occurs */ - public Task[] addDocumentsInBatches(String document, Integer batchSize, String primaryKey) + public TaskInfo[] addDocumentsInBatches(String document, Integer batchSize, String primaryKey) throws MeilisearchException { JSONArray jsonDocumentsArray = new JSONArray(document); JSONArray jsonSubArray = new JSONArray(); - List arrayResponses = new ArrayList(); + List arrayResponses = new ArrayList(); batchSize = jsonDocumentsArray.length() < batchSize ? jsonDocumentsArray.length() : batchSize; @@ -161,7 +161,7 @@ public Task[] addDocumentsInBatches(String document, Integer batchSize, String p arrayResponses.add( this.documents.addDocuments(this.uid, jsonSubArray.toString(), primaryKey)); } - return arrayResponses.toArray(new Task[arrayResponses.size()]); + return arrayResponses.toArray(new TaskInfo[arrayResponses.size()]); } /** @@ -169,10 +169,10 @@ public Task[] addDocumentsInBatches(String document, Integer batchSize, String p * https://docs.meilisearch.com/reference/api/documents.html#add-or-replace-documents * * @param document Document to add in JSON string format - * @return Task Meilisearch API response + * @return TaskInfo Meilisearch API response * @throws MeilisearchException if an error occurs */ - public Task[] addDocumentsInBatches(String document) throws MeilisearchException { + public TaskInfo[] addDocumentsInBatches(String document) throws MeilisearchException { return this.addDocumentsInBatches(document, 1000, null); } @@ -181,10 +181,10 @@ public Task[] addDocumentsInBatches(String document) throws MeilisearchException * https://docs.meilisearch.com/reference/api/documents.html#add-or-update-documents * * @param document Document to update in JSON string format - * @return Task Meilisearch API response + * @return TaskInfo Meilisearch API response * @throws MeilisearchException if an error occurs */ - public Task updateDocuments(String document) throws MeilisearchException { + public TaskInfo updateDocuments(String document) throws MeilisearchException { return this.documents.updateDocuments(this.uid, document, null); } @@ -194,10 +194,11 @@ public Task updateDocuments(String document) throws MeilisearchException { * * @param document Document to update in JSON string format * @param primaryKey PrimaryKey of the document - * @return Task Meilisearch API response + * @return TaskInfo Meilisearch API response * @throws MeilisearchException if an error occurs */ - public Task updateDocuments(String document, String primaryKey) throws MeilisearchException { + public TaskInfo updateDocuments(String document, String primaryKey) + throws MeilisearchException { return this.documents.updateDocuments(this.uid, document, primaryKey); } @@ -208,15 +209,15 @@ public Task updateDocuments(String document, String primaryKey) throws Meilisear * @param document Document to add in JSON string format * @param batchSize size of the batch of documents * @param primaryKey PrimaryKey of the document to add - * @return Task Meilisearch API response + * @return TaskInfo Meilisearch API response * @throws MeilisearchException if an error occurs */ - public Task[] updateDocumentsInBatches(String document, Integer batchSize, String primaryKey) - throws MeilisearchException { + public TaskInfo[] updateDocumentsInBatches( + String document, Integer batchSize, String primaryKey) throws MeilisearchException { JSONArray jsonDocumentsArray = new JSONArray(document); JSONArray jsonSubArray = new JSONArray(); - List arrayResponses = new ArrayList(); + List arrayResponses = new ArrayList(); batchSize = jsonDocumentsArray.length() < batchSize ? jsonDocumentsArray.length() : batchSize; @@ -228,7 +229,7 @@ public Task[] updateDocumentsInBatches(String document, Integer batchSize, Strin arrayResponses.add( this.documents.updateDocuments(this.uid, jsonSubArray.toString(), primaryKey)); } - return arrayResponses.toArray(new Task[arrayResponses.size()]); + return arrayResponses.toArray(new TaskInfo[arrayResponses.size()]); } /** @@ -236,10 +237,10 @@ public Task[] updateDocumentsInBatches(String document, Integer batchSize, Strin * https://docs.meilisearch.com/reference/api/documents.html#add-or-update-documents * * @param document Document to add in JSON string format - * @return Task Meilisearch API response + * @return TaskInfo Meilisearch API response * @throws MeilisearchException if an error occurs */ - public Task[] updateDocumentsInBatches(String document) throws MeilisearchException { + public TaskInfo[] updateDocumentsInBatches(String document) throws MeilisearchException { return this.updateDocumentsInBatches(document, 1000, null); } @@ -248,10 +249,10 @@ public Task[] updateDocumentsInBatches(String document) throws MeilisearchExcept * https://docs.meilisearch.com/reference/api/documents.html#delete-one-document * * @param identifier Identifier of the document to delete - * @return Task Meilisearch API response + * @return TaskInfo Meilisearch API response * @throws MeilisearchException if an error occurs */ - public Task deleteDocument(String identifier) throws MeilisearchException { + public TaskInfo deleteDocument(String identifier) throws MeilisearchException { return this.documents.deleteDocument(this.uid, identifier); } @@ -260,10 +261,10 @@ public Task deleteDocument(String identifier) throws MeilisearchException { * https://docs.meilisearch.com/reference/api/documents.html#delete-documents-by-batch * * @param documentsIdentifiers list of identifiers of documents to delete - * @return Task Meilisearch API response + * @return TaskInfo Meilisearch API response * @throws MeilisearchException if an error occurs */ - public Task deleteDocuments(List documentsIdentifiers) throws MeilisearchException { + public TaskInfo deleteDocuments(List documentsIdentifiers) throws MeilisearchException { return this.documents.deleteDocuments(this.uid, documentsIdentifiers); } @@ -274,7 +275,7 @@ public Task deleteDocuments(List documentsIdentifiers) throws Meilisearc * @return List of tasks Meilisearch API response * @throws MeilisearchException if an error occurs */ - public Task deleteAllDocuments() throws MeilisearchException { + public TaskInfo deleteAllDocuments() throws MeilisearchException { return this.documents.deleteAllDocuments(this.uid); } @@ -326,10 +327,10 @@ public Settings getSettings() throws MeilisearchException { * https://docs.meilisearch.com/reference/api/settings.html#update-settings * * @param settings the object that contains the data with the new settings - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task updateSettings(Settings settings) throws MeilisearchException { + public TaskInfo updateSettings(Settings settings) throws MeilisearchException { return this.settingsHandler.updateSettings(this.uid, settings); } @@ -337,10 +338,10 @@ public Task updateSettings(Settings settings) throws MeilisearchException { * Resets the settings of the index Refer * https://docs.meilisearch.com/reference/api/settings.html#reset-settings * - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task resetSettings() throws MeilisearchException { + public TaskInfo resetSettings() throws MeilisearchException { return this.settingsHandler.resetSettings(this.uid); } @@ -360,10 +361,10 @@ public String[] getRankingRuleSettings() throws MeilisearchException { * https://docs.meilisearch.com/reference/api/settings.html#update-settings * * @param rankingRules array that contain the data with the new ranking rules - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task updateRankingRuleSettings(String[] rankingRules) throws MeilisearchException { + public TaskInfo updateRankingRuleSettings(String[] rankingRules) throws MeilisearchException { return this.settingsHandler.updateRankingRuleSettings(this.uid, rankingRules); } @@ -371,10 +372,10 @@ public Task updateRankingRuleSettings(String[] rankingRules) throws MeilisearchE * Resets the ranking rule settings of the index Refer * https://docs.meilisearch.com/reference/api/settings.html#reset-settings * - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task resetRankingRuleSettings() throws MeilisearchException { + public TaskInfo resetRankingRuleSettings() throws MeilisearchException { return this.settingsHandler.resetRankingRulesSettings(this.uid); } @@ -394,10 +395,11 @@ public Map getSynonymsSettings() throws MeilisearchException { * https://docs.meilisearch.com/reference/api/synonyms.html#update-synonyms * * @param synonyms key (String) value (array) pair of synonyms - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task updateSynonymsSettings(Map synonyms) throws MeilisearchException { + public TaskInfo updateSynonymsSettings(Map synonyms) + throws MeilisearchException { return this.settingsHandler.updateSynonymsSettings(this.uid, synonyms); } @@ -405,10 +407,10 @@ public Task updateSynonymsSettings(Map synonyms) throws Meilis * Resets the synonyms settings of the index Refer * https://docs.meilisearch.com/reference/api/synonyms.html#reset-synonyms * - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task resetSynonymsSettings() throws MeilisearchException { + public TaskInfo resetSynonymsSettings() throws MeilisearchException { return this.settingsHandler.resetSynonymsSettings(this.uid); } @@ -428,10 +430,10 @@ public String[] getStopWordsSettings() throws MeilisearchException { * https://docs.meilisearch.com/reference/api/stop_words.html#update-stop-words * * @param stopWords An array of strings that contains the stop-words. - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task updateStopWordsSettings(String[] stopWords) throws MeilisearchException { + public TaskInfo updateStopWordsSettings(String[] stopWords) throws MeilisearchException { return this.settingsHandler.updateStopWordsSettings(this.uid, stopWords); } @@ -439,10 +441,10 @@ public Task updateStopWordsSettings(String[] stopWords) throws MeilisearchExcept * Resets the stop-words settings of the index Refer * https://docs.meilisearch.com/reference/api/stop_words.html#reset-stop-words * - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task resetStopWordsSettings() throws MeilisearchException { + public TaskInfo resetStopWordsSettings() throws MeilisearchException { return this.settingsHandler.resetStopWordsSettings(this.uid); } @@ -462,10 +464,10 @@ public String[] getSearchableAttributesSettings() throws MeilisearchException { * https://docs.meilisearch.com/reference/api/searchable_attributes.html#update-searchable-attributes * * @param searchableAttributes An array of strings that contains the searchable attributes. - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task updateSearchableAttributesSettings(String[] searchableAttributes) + public TaskInfo updateSearchableAttributesSettings(String[] searchableAttributes) throws MeilisearchException { return this.settingsHandler.updateSearchableAttributesSettings( this.uid, searchableAttributes); @@ -475,10 +477,10 @@ public Task updateSearchableAttributesSettings(String[] searchableAttributes) * Resets the searchable attributes of the index Refer * https://docs.meilisearch.com/reference/api/searchable_attributes.html#reset-searchable-attributes * - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task resetSearchableAttributesSettings() throws MeilisearchException { + public TaskInfo resetSearchableAttributesSettings() throws MeilisearchException { return this.settingsHandler.resetSearchableAttributesSettings(this.uid); } @@ -498,10 +500,10 @@ public String[] getDisplayedAttributesSettings() throws MeilisearchException { * https://docs.meilisearch.com/reference/api/displayed_attributes.html#update-displayed-attributes * * @param displayAttributes An array of strings that contains attributes of an index to display - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task updateDisplayedAttributesSettings(String[] displayAttributes) + public TaskInfo updateDisplayedAttributesSettings(String[] displayAttributes) throws MeilisearchException { return this.settingsHandler.updateDisplayedAttributesSettings(this.uid, displayAttributes); } @@ -510,10 +512,10 @@ public Task updateDisplayedAttributesSettings(String[] displayAttributes) * Resets the displayed attributes of the index Refer * https://docs.meilisearch.com/reference/api/displayed_attributes.html#reset-displayed-attributes * - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task resetDisplayedAttributesSettings() throws MeilisearchException { + public TaskInfo resetDisplayedAttributesSettings() throws MeilisearchException { return this.settingsHandler.resetDisplayedAttributesSettings(this.uid); } @@ -535,10 +537,10 @@ public String[] getFilterableAttributesSettings() throws MeilisearchException { * * @param filterableAttributes An array of strings containing the attributes that can be used as * filters at query time. - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task updateFilterableAttributesSettings(String[] filterableAttributes) + public TaskInfo updateFilterableAttributesSettings(String[] filterableAttributes) throws MeilisearchException { return this.settingsHandler.updateFilterableAttributesSettings( this.uid, filterableAttributes); @@ -548,10 +550,10 @@ public Task updateFilterableAttributesSettings(String[] filterableAttributes) * Resets the filterable attributes of the index Refer * https://docs.meilisearch.com/reference/api/filterable_attributes.html#reset-filterable-attributes * - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task resetFilterableAttributesSettings() throws MeilisearchException { + public TaskInfo resetFilterableAttributesSettings() throws MeilisearchException { return this.settingsHandler.resetFilterableAttributesSettings(this.uid); } @@ -571,10 +573,10 @@ public String getDistinctAttributeSettings() throws MeilisearchException { * https://docs.meilisearch.com/reference/api/distinct_attribute.html#update-distinct-attribute * * @param distinctAttribute A String: the field name. - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task updateDistinctAttributeSettings(String distinctAttribute) + public TaskInfo updateDistinctAttributeSettings(String distinctAttribute) throws MeilisearchException { return this.settingsHandler.updateDistinctAttributeSettings(this.uid, distinctAttribute); } @@ -583,10 +585,10 @@ public Task updateDistinctAttributeSettings(String distinctAttribute) * Resets the distinct attribute field of the index Refer * https://docs.meilisearch.com/reference/api/distinct_attribute.html#reset-distinct-attribute * - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task resetDistinctAttributeSettings() throws MeilisearchException { + public TaskInfo resetDistinctAttributeSettings() throws MeilisearchException { return this.settingsHandler.resetDistinctAttributeSettings(this.uid); } @@ -606,10 +608,10 @@ public TypoTolerance getTypoToleranceSettings() throws MeilisearchException { * https://docs.meilisearch.com/reference/api/typo_tolerance.html#update-typo-tolerance * * @param typoTolerance A TypoTolerance instance - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task updateTypoToleranceSettings(TypoTolerance typoTolerance) + public TaskInfo updateTypoToleranceSettings(TypoTolerance typoTolerance) throws MeilisearchException { return this.settingsHandler.updateTypoToleranceSettings(this.uid, typoTolerance); } @@ -618,10 +620,10 @@ public Task updateTypoToleranceSettings(TypoTolerance typoTolerance) * Resets the typo tolerance field of the index Refer * https://docs.meilisearch.com/reference/api/typo_tolerance.html#reset-typo-tolerance * - * @return Task instance + * @return TaskInfo instance * @throws MeilisearchException if an error occurs */ - public Task resetTypoToleranceSettings() throws MeilisearchException { + public TaskInfo resetTypoToleranceSettings() throws MeilisearchException { return this.settingsHandler.resetTypoToleranceSettings(this.uid); } @@ -645,7 +647,7 @@ public IndexStats getStats() throws MeilisearchException { * @throws MeilisearchException if an error occurs */ public Task getTask(int taskId) throws MeilisearchException { - return this.tasksHandler.getTask(this.uid, taskId); + return this.tasksHandler.getTask(taskId); } /** @@ -655,10 +657,22 @@ public Task getTask(int taskId) throws MeilisearchException { * @return List of tasks in the Meilisearch index * @throws MeilisearchException if an error occurs */ - public Results getTasks() throws MeilisearchException { + public TasksResults getTasks() throws MeilisearchException { return this.tasksHandler.getTasks(this.uid); } + /** + * Retrieves list of tasks of the index Refer + * https://docs.meilisearch.com/reference/api/tasks.html#get-tasks + * + * @param param accept by the tasks route + * @return List of tasks in the Meilisearch index + * @throws MeilisearchException if an error occurs + */ + public TasksResults getTasks(TasksQuery param) throws MeilisearchException { + return this.tasksHandler.getTasks(this.uid, param); + } + /** * Waits for a task to be processed Refer * https://docs.meilisearch.com/reference/api/tasks.html#task-object