This guide will take you step-by-step through the creation of a Node.js script to upload data indexed by Algolia to Meilisearch.
node.js
: 16.16
algoliasearch
: 4.13
meilisearch-js
: 0.27.0
meilisearch
: 0.28
algolia-meilisearch-migration
and generating a package.json
file with npm
:
script.js
file:
algoliasearch
, the JavaScript client for the Algolia API, and the second is meilisearch
, the JavaScript client for the Meilisearch API.
script.js
:
APPLICATION_ID
and ADMIN_API_KEY
with your Algolia application ID and admin API key respectively.
Replace INDEX_NAME
with the name of the Algolia index you would like to migrate to Meilisearch.
browseObjects
method.
batch
callback method is invoked on each batch of hits and the content is concatenated in the records
array. We will use records
again later in the upload process.
MEILI_HOST
,MEILI_API_KEY
, and MEILI_INDEX_NAME
with your Meilisearch host URL, Meilisearch API key, and the index name where you would like to add documents. Meilisearch will create the index if it doesn’t already exist.
addDocumentsInBatches
to upload all your records in batches of 100,000.
sortableAttributes
to use the search parameter sort
. However, unlike in Algolia, an index setting can never be used as a parameter and vice versa.
Algolia | Meilisearch |
---|---|
query | q |
attributesToRetrieve | attributesToRetrieve |
filters | filter |
facets | facetDistribution |
attributesToHighlight | attributesToHighlight |
offset | offset |
length | limit |
typoTolerance | typoTolerance |
snippetEllipsisText | cropMarker |
searchableAttributes | searchableAttributes |
attributesForFaceting | filterableAttributes |
unretrievableAttributes | No direct equivalent; achieved by removing attributes from displayedAttributes |
attributesToRetrieve | displayedAttributes |
attributeForDistinct | distinctAttribute |
ranking | rankingRules |
customRanking | Integrated within rankingRules |
removeStopWords | stopWords |
synonyms | synonyms |
Sorting(using replicas) | sortableAttributes (no replicas required) |
removeWordsIfNoResults | Automatically supported, but not customizable |
disableTypoToleranceOnAttributes | typoTolerance.disableOnAttributes |
separatorsToIndex | Not Supported |
disablePrefixOnAttributes | Not Supported |
relevancyStrictness | Not Supported |
maxValuesPerFacet | maxValuesPerFacet |
sortFacetValuesBy | sortFacetValuesBy |
restrictHighlightAndSnippetArrays | Not Supported |
Method | Algolia | Meilisearch |
---|---|---|
Index Instantiation | client.initIndex() Here, client is an Algolia instance. | client.index() Here, client is a Meilisearch instance. |
Create Index | Algolia automatically creates an index the first time you add a record or settings. | The same applies to Meilisearch, but users can also create an index explicitly: client.createIndex(string indexName) |
Get All Indexes | client.listIndices() | client.getIndexes() |
Get Single Index | No method available | client.getIndex(string indexName) |
Delete Index | index.delete() | client.deleteIndex(string indexName) |
Get Index Settings | index.getSettings() | index().getSettings() |
Update Index Settings | index.setSettings(object settings) | index().updateSettings(object settings) |
Search Method | index.search(string query, { searchParameters, requestOptions }) | index.search(string query, object searchParameters) |
Add Object | index.saveObjects(array objects) | index.addDocuments(array objects) |
Partial Update Object | index.partialUpdateObjects(array objects) | index.updateDocuments(array objects) |
Delete All Objects | index.deleteObjects(array objectIDs) | index.deleteAllDocuments() |
Delete One Object | index.deleteObject(string objectID) | index.deleteDocument(string id) |
Get All Objects | index.getObjects(array objectIDs) | index.getDocuments(object params) |
Get Single Object | index.getObject(str objectID) | index.getDocument(string id) |
Get API Keys | client.listApiKeys() | client.getKeys() |
Get API Key Info | client.getApiKey(string apiKey) | client.getKey(string apiKey) |
Create API Key | client.addApiKey(array acl) | client.createKey(object configuration) |
Update API Key | client.updateApiKey(string apiKey, object configuration) | client.updateKey(string apiKey, object configuration) |
Delete API Key | client.deleteApiKey(string apiKey) | client.deleteKey(string apiKey) |