Search API client
The Search API client is part of the algoliasearch
package.
To install this package, run:
1
npm install algoliasearch
To use the Search client:
1
2
3
4
import { algoliasearch } from "algoliasearch";
const client = algoliasearch("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");
const searchClient = client.initSearch();
The algoliasearch
package includes API clients for the Search, Recommend, Analytics, A/B testing, and Personalization API.
If you just want to use the Search API client, you can install its package on its own:
1
npm install @algolia/client-search
To use it, run:
1
2
3
4
5
6
import { searchClient } from "@algolia/client-search";
const client = searchClient(
"ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY"
);
If you just want to use the Search method of the Search API
to search multiple indices for matching records or facet values, you can use the liteClient
:
1
2
3
import { liteClient } from "algoliasearch/lite";
const client = liteClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");
List of methods
Each method makes one request to the Search API. The Search API client also includes helper methods that wrap one or more of these methods. For more information, see Helper methods.
Search
client.searchSingleIndex | Search an index |
client.search | Search multiple indices |
client.searchForFacetValues | Search for facet values |
client.browse | Browse for records |
Records
client.saveObject | Add or replace a record |
client.getObject | Retrieve a record |
client.addOrUpdateObject | Add or replace a record |
client.deleteObject | Delete a record |
client.deleteBy | Delete records matching a query |
client.clearObjects | Delete all records from an index |
client.partialUpdateObject | Add or update attributes |
client.batch | Batch indexing operations on one index |
client.multipleBatch | Batch indexing operations on multiple indices |
client.getObjects | Retrieve records |
Indices
client.deleteIndex | Delete an index |
client.getSettings | Retrieve index settings |
client.setSettings | Update index settings |
client.getTask | Check task status |
client.operationIndex | Copy or move an index |
client.listIndices | List indices |
Synonyms
client.getSynonym | Retrieve a synonym |
client.saveSynonym | Create or replace a synonym |
client.deleteSynonym | Delete a synonym |
client.saveSynonyms | Create or replace synonyms |
client.clearSynonyms | Delete all synonyms |
client.searchSynonyms | Search for synonyms |
API keys
client.listApiKeys | List API keys |
client.addApiKey | Create an API key |
client.getApiKey | Retrieve API key permissions |
client.updateApiKey | Update an API key |
client.deleteApiKey | Delete an API key |
client.restoreApiKey | Restore an API key |
Rules
client.getRule | Retrieve a rule |
client.saveRule | Create or replace a rule |
client.deleteRule | Delete a rule |
client.saveRules | Create or update rules |
client.clearRules | Delete all rules |
client.searchRules | Search for rules |
Dictionaries
client.batchDictionaryEntries | Add or delete dictionary entries |
client.searchDictionaryEntries | Search dictionary entries |
client.getDictionarySettings | Retrieve dictionary settings |
client.setDictionarySettings | Update dictionary settings |
client.getDictionaryLanguages | List available languages |
Clusters
client.listUserIds | List user IDs |
client.assignUserId | Assign or move a user ID |
client.batchAssignUserIds | Assign multiple userIDs |
client.getTopUserIds | Get top user IDs |
client.getUserId | Retrieve user ID |
client.removeUserId | Delete user ID |
client.listClusters | List clusters |
client.searchUserIds | Search for user IDs |
client.hasPendingMappings | Get migration and user mapping status |
Vaults
client.getSources | List allowed sources |
client.replaceSources | Replace allowed sources |
client.appendSource | Add a source |
client.deleteSource | Delete a source |
Advanced
client.getLogs | Retrieve log entries |
client.getAppTask | Check application task status |