Migration guide
This document lists every known breaking change, not all of them may affect your application.
caution
The amount of changes in this new version is significant. If you were using a version older than v4, please also read this migration guide
You should thoroughly test your application once the migration is over.
Common breaking changes
The changes below are effective on all of the API clients.
Previous | Latest | Description |
---|---|---|
initIndex | removed | All methods are now available at the client level. See example below |
Client's specific breaking changes
The changes below are effective on the selected API client. For information regarding the installation of the package, please see the installation page.
- JavaScript
Previous | Latest | Impacted clients | Description |
---|---|---|---|
@algolia | @experimental-api-clients-automation | JavaScript | During the beta phase, the clients are available under the NPM @experimental-api-clients-automation namespace, you can find a full list here. |
algoliasearch/lite | algoliasearch-lite | JavaScript | The lite version of the client now have its own package. |
search | searchClient | all | Exported clients are suffixed by Client . |
Usage
- JavaScript
Previous | Latest | Impacted clients | Description |
---|---|---|---|
@algolia | @experimental-api-clients-automation | JavaScript | During the beta phase, the clients are available under the NPM @experimental-api-clients-automation namespace, you can find a full list here. |
algoliasearch/lite | algoliasearch-lite | JavaScript | The lite version of the client now have its own package. |
search | searchClient | all | Exported clients are suffixed by Client . |
To get started, first install the algoliasearch
client.
bash
yarn add @experimental-api-clients-automation/algoliasearch# ornpm install @experimental-api-clients-automation/algoliasearch
bash
yarn add @experimental-api-clients-automation/algoliasearch# ornpm install @experimental-api-clients-automation/algoliasearch
You can now uninstall the previously added client.
Make sure to update all your imports.
bash
yarn remove algoliasearch# ornpm uninstall algoliasearch
bash
yarn remove algoliasearch# ornpm uninstall algoliasearch
You can continue this guide on our installation page.
Importing algoliasearch using ES Modules
diff
- import algoliasearch from 'algoliasearch/lite';+ import { algoliasearchLiteClient } from '@experimental-api-clients-automation/algoliasearch-lite';- import algoliasearch from 'algoliasearch';+ import { algoliasearch } from '@experimental-api-clients-automation/algoliasearch';
diff
- import algoliasearch from 'algoliasearch/lite';+ import { algoliasearchLiteClient } from '@experimental-api-clients-automation/algoliasearch-lite';- import algoliasearch from 'algoliasearch';+ import { algoliasearch } from '@experimental-api-clients-automation/algoliasearch';
Methods targeting an indexName
- JavaScript
Prior to the initIndex
removal stated in the Common breaking changes, all methods previously available at the initIndex
level requires the indexName
to be sent with the query.
js
import { algoliasearch } from '@experimental-api-clients-automation/algoliasearch';const client = algoliasearch('<YOUR_APP_ID>', '<YOUR_API_KEY>');// only query stringconst searchResults = await client.search({requests: [{indexName: '<YOUR_INDEX_NAME>',query: '<YOUR_QUERY>',},],});// with paramsconst searchResults2 = await client.search({requests: [{indexName: '<YOUR_INDEX_NAME>',query: '<YOUR_QUERY>',attributesToRetrieve: ['firstname', 'lastname'],hitsPerPage: 50,},],});
js
import { algoliasearch } from '@experimental-api-clients-automation/algoliasearch';const client = algoliasearch('<YOUR_APP_ID>', '<YOUR_API_KEY>');// only query stringconst searchResults = await client.search({requests: [{indexName: '<YOUR_INDEX_NAME>',query: '<YOUR_QUERY>',},],});// with paramsconst searchResults2 = await client.search({requests: [{indexName: '<YOUR_INDEX_NAME>',query: '<YOUR_QUERY>',attributesToRetrieve: ['firstname', 'lastname'],hitsPerPage: 50,},],});