Package com.algolia.search
Class SearchClient
- java.lang.Object
-
- com.algolia.search.SearchClient
-
- All Implemented Interfaces:
SearchClientAdvanced,SearchClientAPIKeys,SearchClientBase,SearchClientCopyOperations,SearchClientDictionary,SearchClientMcm,SearchClientMultipleOperations,SearchClientPersonalization,Closeable,AutoCloseable
public final class SearchClient extends Object implements Closeable, SearchClientMultipleOperations, SearchClientCopyOperations, SearchClientMcm, SearchClientAPIKeys, SearchClientPersonalization, SearchClientAdvanced, SearchClientDictionary
Algolia's REST search client that wraps an instance of the transporterHttpTransportwhich wraps the HttpClient This client allows to build typed requests and read typed responses. Requests are made under the Algolia's retry-strategy. This client is intended to be reused and it's thread-safe.- See Also:
- Algolia.com
-
-
Constructor Summary
Constructors Constructor Description SearchClient(SearchConfig config, HttpRequester httpRequester)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the underlying HttpClient and resources.TaskStatusResponsegetAppTask(long taskID)Get the status of the given dictionary task.TaskStatusResponsegetAppTask(long taskID, RequestOptions requestOptions)Get the status of the given dictionary task.CompletableFuture<TaskStatusResponse>getAppTaskAsync(long taskID)Get the status of the given dictionary task.CompletableFuture<TaskStatusResponse>getAppTaskAsync(long taskID, RequestOptions requestOptions)Get the status of the given dictionary task.ConfigBasegetConfig()Get Client's configurationHttpTransportgetTransport()SearchIndex<?>initIndex(String indexName)Get the index object initialized (no server call needed for initialization)<T> SearchIndex<T>initIndex(String indexName, Class<T> clazz)Get the index object initialized (no server call needed for initialization)voidwaitAppTask(long taskID)Wait for a dictionary task to complete before executing the next line of code.voidwaitAppTask(long taskID, long timeToWait, RequestOptions requestOptions)Wait for a dictionary task to complete before executing the next line of code.voidwaitAppTask(long taskID, RequestOptions requestOptions)Wait for a dictionary task to complete before executing the next line of code.voidwaitTask(String indexName, long taskID)Wait for a task to complete before executing the next line of code, to synchronize index updates.voidwaitTask(String indexName, long taskID, long timeToWait)Wait for a task to complete before executing the next line of code, to synchronize index updates.voidwaitTask(String indexName, long taskID, long timeToWait, RequestOptions requestOptions)Wait for a task to complete before executing the next line of code, to synchronize index updates.voidwaitTask(String indexName, long taskID, RequestOptions requestOptions)Wait for a task to complete before executing the next line of code, to synchronize index updates.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.algolia.search.SearchClientAdvanced
customRequest, customRequest, customRequest, customRequest, customRequestAsync, customRequestAsync, customRequestAsync, customRequestAsync, getLogs, getLogs, getLogs, getLogs, getLogs, getLogsAsync, getLogsAsync, getLogsAsync, getLogsAsync, getLogsAsync, listIndices, listIndices, listIndicesAsync, listIndicesAsync
-
Methods inherited from interface com.algolia.search.SearchClientAPIKeys
addApiKey, addApiKey, addApiKeyAsync, addApiKeyAsync, deleteApiKey, deleteApiKey, deleteApiKeyAsync, deleteApiKeyAsync, generateSecuredAPIKey, getApiKey, getApiKey, getApiKeyAsync, getApiKeyAsync, getSecuredApiKeyRemainingValidity, listApiKeys, listApiKeys, listApiKeysAsync, listApiKeysAsync, restoreApiKey, restoreApiKey, restoreApiKeyAsync, restoreApiKeyAsync, updateApiKey, updateApiKey, updateApiKeyAsync, updateApiKeyAsync
-
Methods inherited from interface com.algolia.search.SearchClientCopyOperations
checkIndicesBeforeMoving, copyIndex, copyIndex, copyIndex, copyIndexAsync, copyIndexAsync, copyIndexAsync, copyRules, copyRules, copyRulesAsync, copyRulesAsync, copySettings, copySettings, copySettingsAsync, copySettingsAsync, copySynonyms, copySynonyms, copySynonymsAsync, copySynonymsAsync, moveIndex, moveIndex, moveIndexAsync, moveIndexAsync
-
Methods inherited from interface com.algolia.search.SearchClientDictionary
clearDictionaryEntries, clearDictionaryEntries, clearDictionaryEntriesAsync, clearDictionaryEntriesAsync, deleteDictionaryEntries, deleteDictionaryEntries, deleteDictionaryEntriesAsync, deleteDictionaryEntriesAsync, getDictionarySettings, getDictionarySettings, getDictionarySettingsAsync, getDictionarySettingsAsync, replaceDictionaryEntries, replaceDictionaryEntries, replaceDictionaryEntriesAsync, replaceDictionaryEntriesAsync, saveDictionaryEntries, saveDictionaryEntries, saveDictionaryEntriesAsync, saveDictionaryEntriesAsync, searchDictionaryEntries, searchDictionaryEntries, searchDictionaryEntriesAsync, searchDictionaryEntriesAsync, setDictionarySettings, setDictionarySettings, setDictionarySettingsAsync, setDictionarySettingsAsync
-
Methods inherited from interface com.algolia.search.SearchClientMcm
assignUserID, assignUserID, assignUserIDAsync, assignUserIDAsync, assignUserIDs, assignUserIDs, assignUserIDsAsync, assignUserIDsAsync, getTopUserID, getTopUserID, getTopUserIDAsync, getTopUserIDAsync, getUserID, getUserID, getUserIDAsync, getUserIDAsync, hasPendingMappings, hasPendingMappings, hasPendingMappings, hasPendingMappings, hasPendingMappingsAsync, hasPendingMappingsAsync, hasPendingMappingsAsync, hasPendingMappingsAsync, listClusters, listClusters, listClustersAsync, listClustersAsync, listUserIDs, listUserIDs, listUserIDs, listUserIDsAsync, listUserIDsAsync, listUserIDsAsync, removeUserID, removeUserID, removeUserIDAsync, removeUserIDAsync, searchUserIDs, searchUserIDs, searchUserIDsAsync, searchUserIDsAsync
-
Methods inherited from interface com.algolia.search.SearchClientMultipleOperations
multipleBatch, multipleBatch, multipleBatchAsync, multipleBatchAsync, multipleGetObjects, multipleGetObjects, multipleGetObjectsAsync, multipleGetObjectsAsync, multipleQueries, multipleQueries, multipleQueriesAsync, multipleQueriesAsync
-
Methods inherited from interface com.algolia.search.SearchClientPersonalization
getPersonalizationStrategy, getPersonalizationStrategy, getPersonalizationStrategyAsync, getPersonalizationStrategyAsync, setPersonalizationStrategy, setPersonalizationStrategy, setPersonalizationStrategyAsync, setPersonalizationStrategyAsync
-
-
-
-
Constructor Detail
-
SearchClient
public SearchClient(@Nonnull SearchConfig config, @Nonnull HttpRequester httpRequester)
- Parameters:
config- The configuration allows you to advanced configuration of the clients such as batch size or custom hosts and timeout.httpRequester- Another HTTP Client than the default one. Must be an implementation ofHttpRequester.- Throws:
NullPointerException- If one of the following ApplicationID/ApiKey/Config/Requester is nullIllegalArgumentException- If the ApplicationID or the APIKey are empty
-
-
Method Detail
-
close
public void close() throws IOExceptionClose the underlying HttpClient and resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if an I/O error occurs
-
getTransport
public HttpTransport getTransport()
- Specified by:
getTransportin interfaceSearchClientBase
-
getConfig
public ConfigBase getConfig()
Get Client's configuration- Specified by:
getConfigin interfaceSearchClientBase
-
initIndex
public SearchIndex<?> initIndex(@Nonnull String indexName)
Get the index object initialized (no server call needed for initialization)- Parameters:
indexName- The name of the Algolia index- Throws:
IllegalArgumentException- When indexName is null or empty
-
initIndex
public <T> SearchIndex<T> initIndex(@Nonnull String indexName, @Nonnull Class<T> clazz)
Get the index object initialized (no server call needed for initialization)- Type Parameters:
T- the type of the objects in this index- Parameters:
indexName- The name of the Algolia indexclazz- class of the object in this index- Throws:
IllegalArgumentException- When indexName is null or empty
-
waitTask
public void waitTask(@Nonnull String indexName, long taskID)
Wait for a task to complete before executing the next line of code, to synchronize index updates. All write operations in Algolia are asynchronous by design.- Specified by:
waitTaskin interfaceSearchClientBase- Parameters:
indexName- The indexName to wait ontaskID- The Algolia taskID- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
waitTask
public void waitTask(@Nonnull String indexName, long taskID, long timeToWait)
Wait for a task to complete before executing the next line of code, to synchronize index updates. All write operations in Algolia are asynchronous by design.- Parameters:
indexName- The indexName to wait ontaskID- The Algolia taskIDtimeToWait- The time to wait between each call- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
waitTask
public void waitTask(@Nonnull String indexName, long taskID, RequestOptions requestOptions)
Wait for a task to complete before executing the next line of code, to synchronize index updates. All write operations in Algolia are asynchronous by design.- Parameters:
indexName- The indexName to wait ontaskID- The Algolia taskIDrequestOptions- Options to pass to this request- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
waitTask
public void waitTask(@Nonnull String indexName, long taskID, long timeToWait, RequestOptions requestOptions)
Wait for a task to complete before executing the next line of code, to synchronize index updates. All write operations in Algolia are asynchronous by design.- Specified by:
waitTaskin interfaceSearchClientBase- Parameters:
indexName- The indexName to wait ontaskID- The Algolia taskIDtimeToWait- The time to wait between each callrequestOptions- Options to pass to this request- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
waitAppTask
public void waitAppTask(long taskID)
Wait for a dictionary task to complete before executing the next line of code. All write operations in Algolia are asynchronous by design.- Specified by:
waitAppTaskin interfaceSearchClientBase- Parameters:
taskID- The Algolia taskID- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
waitAppTask
public void waitAppTask(long taskID, RequestOptions requestOptions)Wait for a dictionary task to complete before executing the next line of code. All write operations in Algolia are asynchronous by design.- Parameters:
taskID- The Algolia taskIDrequestOptions- Options to pass to this request- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
waitAppTask
public void waitAppTask(long taskID, long timeToWait, RequestOptions requestOptions)Wait for a dictionary task to complete before executing the next line of code. All write operations in Algolia are asynchronous by design.- Specified by:
waitAppTaskin interfaceSearchClientBase- Parameters:
taskID- The Algolia taskIDtimeToWait- The time to wait between each callrequestOptions- Options to pass to this request- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
getAppTask
public TaskStatusResponse getAppTask(long taskID)
Get the status of the given dictionary task.- Parameters:
taskID- The Algolia taskID- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
getAppTask
public TaskStatusResponse getAppTask(long taskID, RequestOptions requestOptions)
Get the status of the given dictionary task.- Parameters:
taskID- The Algolia taskIDrequestOptions- Options to pass to this request- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
getAppTaskAsync
public CompletableFuture<TaskStatusResponse> getAppTaskAsync(long taskID)
Get the status of the given dictionary task.- Parameters:
taskID- The Algolia taskID- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
getAppTaskAsync
public CompletableFuture<TaskStatusResponse> getAppTaskAsync(long taskID, RequestOptions requestOptions)
Get the status of the given dictionary task.- Parameters:
taskID- The Algolia taskIDrequestOptions- Options to pass to this request- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
-