SearchClient class final

Implemented types
Available extensions

Constructors

SearchClient({required String appId, required String apiKey, ClientOptions options = const ClientOptions()})

Properties

hashCode int
The hash code for this object.
no setterinherited
options ClientOptions
A set of custom client options to configure the behavior of the API client.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addApiKey({required ApiKey apiKey, RequestOptions? requestOptions}) Future<AddApiKeyResponse>
Creates a new API key with specific permissions and restrictions.
addOrUpdateObject({required String indexName, required String objectID, required Object body, RequestOptions? requestOptions}) Future<UpdatedAtWithObjectIdResponse>
If a record with the specified object ID exists, the existing record is replaced. Otherwise, a new record is added to the index. If you want to use auto-generated object IDs, use the saveObject operation. To update some attributes of an existing record, use the partial operation instead. To add, update, or replace multiple records, use the batch operation.
appendSource({required Source source, RequestOptions? requestOptions}) Future<CreatedAtResponse>
Adds a source to the list of allowed sources.
assignUserId({required String xAlgoliaUserID, required AssignUserIdParams assignUserIdParams, RequestOptions? requestOptions}) Future<CreatedAtResponse>
Assigns or moves a user ID to a cluster. The time it takes to move a user is proportional to the amount of data linked to the user ID.
batch({required String indexName, required BatchWriteParams batchWriteParams, RequestOptions? requestOptions}) Future<BatchResponse>
Adds, updates, or deletes records in one index with a single API request. Batching index updates reduces latency and increases data integrity. - Actions are applied in the order they're specified. - Actions are equivalent to the individual API requests of the same name. This operation is subject to indexing rate limits.
batchAssignUserIds({required String xAlgoliaUserID, required BatchAssignUserIdsParams batchAssignUserIdsParams, RequestOptions? requestOptions}) Future<CreatedAtResponse>
Assigns multiple user IDs to a cluster. You can't move users with this operation.
batchDictionaryEntries({required DictionaryType dictionaryName, required BatchDictionaryEntriesParams batchDictionaryEntriesParams, RequestOptions? requestOptions}) Future<UpdatedAtResponse>
Adds or deletes multiple entries from your plurals, segmentation, or stop word dictionaries.
browse({required String indexName, dynamic browseParams, RequestOptions? requestOptions}) Future<BrowseResponse>
Retrieves records from an index, up to 1,000 per request. While searching retrieves hits (records augmented with attributes for highlighting and ranking details), browsing just returns matching records. This can be useful if you want to export your indices. - The Analytics API doesn't collect data when using browse. - Records are ranked by attributes and custom ranking. - There's no ranking for: typo-tolerance, number of matched words, proximity, geo distance. Browse requests automatically apply these settings: - advancedSyntax: false - attributesToHighlight: [] - attributesToSnippet: [] - distinct: false - enablePersonalization: false - enableRules: false - facets: [] - getRankingInfo: false - ignorePlurals: false - optionalFilters: [] - typoTolerance: true or false (min and strict evaluate to true) If you send these parameters with your browse requests, they'll be ignored.
clearObjects({required String indexName, RequestOptions? requestOptions}) Future<UpdatedAtResponse>
Deletes only the records from an index while keeping settings, synonyms, and rules. This operation is resource-intensive and subject to indexing rate limits.
clearRules({required String indexName, bool? forwardToReplicas, RequestOptions? requestOptions}) Future<UpdatedAtResponse>
Deletes all rules from the index.
clearSynonyms({required String indexName, bool? forwardToReplicas, RequestOptions? requestOptions}) Future<UpdatedAtResponse>
Deletes all synonyms from the index.
customDelete({required String path, Map<String, Object>? parameters, RequestOptions? requestOptions}) Future<Object>
This method allow you to send requests to the Algolia REST API.
customGet({required String path, Map<String, Object>? parameters, RequestOptions? requestOptions}) Future<Object>
This method allow you to send requests to the Algolia REST API.
customPost({required String path, Map<String, Object>? parameters, Object? body, RequestOptions? requestOptions}) Future<Object>
This method allow you to send requests to the Algolia REST API.
customPut({required String path, Map<String, Object>? parameters, Object? body, RequestOptions? requestOptions}) Future<Object>
This method allow you to send requests to the Algolia REST API.
del({required String path, Map<String, Object>? parameters, Object? body, RequestOptions? requestOptions}) Future<Object>
deleteApiKey({required String key, RequestOptions? requestOptions}) Future<DeleteApiKeyResponse>
Deletes the API key.
deleteBy({required String indexName, required DeleteByParams deleteByParams, RequestOptions? requestOptions}) Future<UpdatedAtResponse>
This operation doesn't accept empty filters. This operation is resource-intensive. You should only use it if you can't get the object IDs of the records you want to delete. It's more efficient to get a list of object IDs with the browse operation, and then delete the records using the batch operation. This operation is subject to indexing rate limits.
deleteIndex({required String indexName, RequestOptions? requestOptions}) Future<DeletedAtResponse>
Deletes an index and all its settings. - Deleting an index doesn't delete its analytics data. - If you try to delete a non-existing index, the operation is ignored without warning. - If the index you want to delete has replica indices, the replicas become independent indices. - If the index you want to delete is a replica index, you must first unlink it from its primary index before you can delete it. For more information, see Delete replica indices.
deleteObject({required String indexName, required String objectID, RequestOptions? requestOptions}) Future<DeletedAtResponse>
Deletes a record by its object ID. To delete more than one record, use the batch operation. To delete records matching a query, use the deleteByQuery operation.
deleteRule({required String indexName, required String objectID, bool? forwardToReplicas, RequestOptions? requestOptions}) Future<UpdatedAtResponse>
Deletes a rule by its ID. To find the object ID for rules, use the search operation.
deleteSource({required String source, RequestOptions? requestOptions}) Future<DeleteSourceResponse>
Deletes a source from the list of allowed sources.
deleteSynonym({required String indexName, required String objectID, bool? forwardToReplicas, RequestOptions? requestOptions}) Future<DeletedAtResponse>
Deletes a synonym by its ID. To find the object IDs of your synonyms, use the search operation.
dispose() → void
Dispose of underlying resources.
override
get({required String path, Map<String, Object>? parameters, Object? body, RequestOptions? requestOptions}) Future<Object>
getApiKey({required String key, RequestOptions? requestOptions}) Future<GetApiKeyResponse>
Gets the permissions and restrictions of an API key. When authenticating with the admin API key, you can request information for any of your application's keys. When authenticating with other API keys, you can only retrieve information for that key, with the description replaced by <redacted>.
getAppTask({required int taskID, RequestOptions? requestOptions}) Future<GetTaskResponse>
Checks the status of a given application task.
getDictionaryLanguages({RequestOptions? requestOptions}) Future<Map<String, Languages>>
Lists supported languages with their supported dictionary types and number of custom entries.
getDictionarySettings({RequestOptions? requestOptions}) Future<GetDictionarySettingsResponse>
Retrieves the languages for which standard dictionary entries are turned off.
getLogs({int? offset, int? length, String? indexName, LogType? type, RequestOptions? requestOptions}) Future<GetLogsResponse>
The request must be authenticated by an API key with the logs ACL. - Logs are held for the last seven days. - Up to 1,000 API requests per server are logged. - This request counts towards your operations quota but doesn't appear in the logs itself.
getObject({required String indexName, required String objectID, List<String>? attributesToRetrieve, RequestOptions? requestOptions}) Future<Object>
Retrieves one record by its object ID. To retrieve more than one record, use the objects operation.
getObjects({required GetObjectsParams getObjectsParams, RequestOptions? requestOptions}) Future<GetObjectsResponse>
Retrieves one or more records, potentially from different indices. Records are returned in the same order as the requests.
getRule({required String indexName, required String objectID, RequestOptions? requestOptions}) Future<Rule>
Retrieves a rule by its ID. To find the object ID of rules, use the search operation.
getSettings({required String indexName, RequestOptions? requestOptions}) Future<SettingsResponse>
Retrieves an object with non-null index settings.
getSources({RequestOptions? requestOptions}) Future<List<Source>>
Retrieves all allowed IP addresses with access to your application.
getSynonym({required String indexName, required String objectID, RequestOptions? requestOptions}) Future<SynonymHit>
Retrieves a synonym by its ID. To find the object IDs for your synonyms, use the search operation.
getTask({required String indexName, required int taskID, RequestOptions? requestOptions}) Future<GetTaskResponse>
Checks the status of a given task. Indexing tasks are asynchronous. When you add, update, or delete records or indices, a task is created on a queue and completed depending on the load on the server. The indexing tasks' responses include a task ID that you can use to check the status.
getTopUserIds({RequestOptions? requestOptions}) Future<GetTopUserIdsResponse>
Get the IDs of the 10 users with the highest number of records per cluster. Since it can take a few seconds to get the data from the different clusters, the response isn't real-time.
getUserId({required String userID, RequestOptions? requestOptions}) Future<UserId>
Returns the user ID data stored in the mapping. Since it can take a few seconds to get the data from the different clusters, the response isn't real-time.
hasPendingMappings({bool? getClusters, RequestOptions? requestOptions}) Future<HasPendingMappingsResponse>
To determine when the time-consuming process of creating a large batch of users or migrating users from one cluster to another is complete, this operation retrieves the status of the process.
listApiKeys({RequestOptions? requestOptions}) Future<ListApiKeysResponse>
Lists all API keys associated with your Algolia application, including their permissions and restrictions.
listClusters({RequestOptions? requestOptions}) Future<ListClustersResponse>
Lists the available clusters in a multi-cluster setup.
listIndices({int? page, int? hitsPerPage, RequestOptions? requestOptions}) Future<ListIndicesResponse>
Lists all indices in the current Algolia application. The request follows any index restrictions of the API key you use to make the request.
listUserIds({int? page, int? hitsPerPage, RequestOptions? requestOptions}) Future<ListUserIdsResponse>
Lists the userIDs assigned to a multi-cluster application. Since it can take a few seconds to get the data from the different clusters, the response isn't real-time.
multipleBatch({required BatchParams batchParams, RequestOptions? requestOptions}) Future<MultipleBatchResponse>
Adds, updates, or deletes records in multiple indices with a single API request. - Actions are applied in the order they are specified. - Actions are equivalent to the individual API requests of the same name. This operation is subject to indexing rate limits.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
operationIndex({required String indexName, required OperationIndexParams operationIndexParams, RequestOptions? requestOptions}) Future<UpdatedAtResponse>
Copies or moves (renames) an index within the same Algolia application. - Existing destination indices are overwritten, except for their analytics data. - If the destination index doesn't exist yet, it'll be created. - This operation is resource-intensive. Copy - Copying a source index that doesn't exist creates a new index with 0 records and default settings. - The API keys of the source index are merged with the existing keys in the destination index. - You can't copy the enableReRanking, mode, and replicas settings. - You can't copy to a destination index that already has replicas. - Be aware of the size limits. - Related guide: Copy indices Move - Moving a source index that doesn't exist is ignored without returning an error. - When moving an index, the analytics data keeps its original name, and a new set of analytics data is started for the new name. To access the original analytics in the dashboard, create an index with the original name. - If the destination index has replicas, moving will overwrite the existing index and copy the data to the replica indices. - Related guide: Move indices. This operation is subject to indexing rate limits.
partialUpdateObject({required String indexName, required String objectID, required Object attributesToUpdate, bool? createIfNotExists, RequestOptions? requestOptions}) Future<UpdatedAtWithObjectIdResponse>
Adds new attributes to a record, or updates existing ones. - If a record with the specified object ID doesn't exist, a new record is added to the index if createIfNotExists is true. - If the index doesn't exist yet, this method creates a new index. - You can use any first-level attribute but not nested attributes. If you specify a nested attribute, this operation replaces its first-level ancestor. To update an attribute without pushing the entire record, you can use these built-in operations. These operations can be helpful if you don't have access to your initial data. - Increment: increment a numeric attribute - Decrement: decrement a numeric attribute - Add: append a number or string element to an array attribute - Remove: remove all matching number or string elements from an array attribute made of numbers or strings - AddUnique: add a number or string element to an array attribute made of numbers or strings only if it's not already present - IncrementFrom: increment a numeric integer attribute only if the provided value matches the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementFrom value of 2 for the version attribute, but the current value of the attribute is 1, the engine ignores the update. If the object doesn't exist, the engine only creates it if you pass an IncrementFrom value of 0. - IncrementSet: increment a numeric integer attribute only if the provided value is greater than the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementSet value of 2 for the version attribute, and the current value of the attribute is 1, the engine updates the object. If the object doesn't exist yet, the engine only creates it if you pass an IncrementSet value greater than 0. You can specify an operation by providing an object with the attribute to update as the key and its value being an object with the following properties: - _operation: the operation to apply on the attribute - value: the right-hand side argument to the operation, for example, increment or decrement step, value to add or remove. This operation is subject to indexing rate limits.
post({required String path, Map<String, Object>? parameters, Object? body, RequestOptions? requestOptions}) Future<Object>
put({required String path, Map<String, Object>? parameters, Object? body, RequestOptions? requestOptions}) Future<Object>
removeUserId({required String userID, RequestOptions? requestOptions}) Future<RemoveUserIdResponse>
Deletes a user ID and its associated data from the clusters.
replaceSources({required List<Source> source, RequestOptions? requestOptions}) Future<ReplaceSourceResponse>
Replaces the list of allowed sources.
restoreApiKey({required String key, RequestOptions? requestOptions}) Future<AddApiKeyResponse>
Restores a deleted API key. Restoring resets the validity attribute to 0. Algolia stores up to 1,000 API keys per application. If you create more, the oldest API keys are deleted and can't be restored.
saveObject({required String indexName, required Object body, RequestOptions? requestOptions}) Future<SaveObjectResponse>
Adds a record to an index or replaces it. - If the record doesn't have an object ID, a new record with an auto-generated object ID is added to your index. - If a record with the specified object ID exists, the existing record is replaced. - If a record with the specified object ID doesn't exist, a new record is added to your index. - If you add a record to an index that doesn't exist yet, a new index is created. To update some attributes of a record, use the partial operation. To add, update, or replace multiple records, use the batch operation. This operation is subject to indexing rate limits.
saveRule({required String indexName, required String objectID, required Rule rule, bool? forwardToReplicas, RequestOptions? requestOptions}) Future<UpdatedAtResponse>
If a rule with the specified object ID doesn't exist, it's created. Otherwise, the existing rule is replaced. To create or update more than one rule, use the batch operation.
saveRules({required String indexName, required List<Rule> rules, bool? forwardToReplicas, bool? clearExistingRules, RequestOptions? requestOptions}) Future<UpdatedAtResponse>
Create or update multiple rules. If a rule with the specified object ID doesn't exist, Algolia creates a new one. Otherwise, existing rules are replaced. This operation is subject to indexing rate limits.
saveSynonym({required String indexName, required String objectID, required SynonymHit synonymHit, bool? forwardToReplicas, RequestOptions? requestOptions}) Future<SaveSynonymResponse>
If a synonym with the specified object ID doesn't exist, Algolia adds a new one. Otherwise, the existing synonym is replaced. To add multiple synonyms in a single API request, use the batch operation.
saveSynonyms({required String indexName, required List<SynonymHit> synonymHit, bool? forwardToReplicas, bool? replaceExistingSynonyms, RequestOptions? requestOptions}) Future<UpdatedAtResponse>
If a synonym with the objectID doesn't exist, Algolia adds a new one. Otherwise, existing synonyms are replaced. This operation is subject to indexing rate limits.
Sends multiple search requests to one or more indices. This can be useful in these cases: - Different indices for different purposes, such as, one index for products, another one for marketing content. - Multiple searches to the same index—for example, with different filters.
searchDictionaryEntries({required DictionaryType dictionaryName, required SearchDictionaryEntriesParams searchDictionaryEntriesParams, RequestOptions? requestOptions}) Future<SearchDictionaryEntriesResponse>
Searches for standard and custom dictionary entries.
searchForFacets({required List<SearchForFacets> requests, SearchStrategy? strategy, RequestOptions? requestOptions}) Future<Iterable<SearchForFacetValuesResponse>>

Available on SearchClient, provided by the SearchClientExt extension

Calls the search method but with certainty that we will only request Algolia facets.
searchForFacetValues({required String indexName, required String facetName, SearchForFacetValuesRequest? searchForFacetValuesRequest, RequestOptions? requestOptions}) Future<SearchForFacetValuesResponse>
Searches for values of a specified facet attribute. - By default, facet values are sorted by decreasing count. You can adjust this with the sortFacetValueBy parameter. - Searching for facet values doesn't work if you have more than 65 searchable facets and searchable attributes combined.
searchForHits({required List<SearchForHits> requests, SearchStrategy? strategy, RequestOptions? requestOptions}) Future<Iterable<SearchResponse>>

Available on SearchClient, provided by the SearchClientExt extension

Calls the search method but with certainty that we will only request Algolia records (hits).
searchIndex({required SearchForHits request, RequestOptions? requestOptions}) Future<SearchResponse>

Available on SearchClient, provided by the SearchClientExt extension

Perform a search operation targeting one index.
searchRules({required String indexName, SearchRulesParams? searchRulesParams, RequestOptions? requestOptions}) Future<SearchRulesResponse>
Searches for rules in your index.
searchSingleIndex({required String indexName, dynamic searchParams, RequestOptions? requestOptions}) Future<SearchResponse>
Searches a single index and returns matching search results (hits). This method lets you retrieve up to 1,000 hits. If you need more, use the browse operation or increase the paginatedLimitedTo index setting.
searchSynonyms({required String indexName, SearchSynonymsParams? searchSynonymsParams, RequestOptions? requestOptions}) Future<SearchSynonymsResponse>
Searches for synonyms in your index.
searchUserIds({required SearchUserIdsParams searchUserIdsParams, RequestOptions? requestOptions}) Future<SearchUserIdsResponse>
Since it can take a few seconds to get the data from the different clusters, the response isn't real-time. To ensure rapid updates, the user IDs index isn't built at the same time as the mapping. Instead, it's built every 12 hours, at the same time as the update of user ID usage. For example, if you add or move a user ID, the search will show an old value until the next time the mapping is rebuilt (every 12 hours).
setClientApiKey({required String apiKey}) → void
Allows to switch the API key used to authenticate requests.
override
setDictionarySettings({required DictionarySettingsParams dictionarySettingsParams, RequestOptions? requestOptions}) Future<UpdatedAtResponse>
Turns standard stop word dictionary entries on or off for a given language.
setSettings({required String indexName, required IndexSettings indexSettings, bool? forwardToReplicas, RequestOptions? requestOptions}) Future<UpdatedAtResponse>
Update the specified index settings. Index settings that you don't specify are left unchanged. Specify null to reset a setting to its default value. For best performance, update the index settings before you add new records to your index.
toString() String
A string representation of this object.
inherited
updateApiKey({required String key, required ApiKey apiKey, RequestOptions? requestOptions}) Future<UpdateApiKeyResponse>
Replaces the permissions of an existing API key. Any unspecified attribute resets that attribute to its default value.
waitAppTask({required int taskID, WaitParams params = const WaitParams(), RequestOptions? requestOptions}) Future<void>

Available on SearchClient, provided by the WaitTask extension

Wait for an application-level taskID to complete before executing the next line of code.
waitKeyCreation({required String key, int maxRetries = 50, WaitParams params = const WaitParams(), RequestOptions? requestOptions}) Future<void>

Available on SearchClient, provided by the WaitTask extension

Wait on an API key creation operation.
waitKeyDeletion({required String key, WaitParams params = const WaitParams(), RequestOptions? requestOptions}) Future<void>

Available on SearchClient, provided by the WaitTask extension

Wait on a delete API ket operation.
waitKeyUpdate({required String key, required ApiKey apiKey, WaitParams params = const WaitParams(), RequestOptions? requestOptions}) Future<void>

Available on SearchClient, provided by the WaitTask extension

Wait on an API key update operation.
waitTask({required String indexName, required int taskID, WaitParams params = const WaitParams(), RequestOptions? requestOptions}) Future<void>

Available on SearchClient, provided by the WaitTask extension

Wait for a taskID to complete before executing the next line of code, to synchronize index updates. All write operations in Algolia are asynchronous by design. It means that when you add or update an object to your index, our servers will reply to your request with a taskID as soon as they understood the write operation. The actual insert and indexing will be done after replying to your code. You can wait for a task to complete by using the taskID and this method.

Operators

operator ==(Object other) bool
The equality operator.
inherited