Introduction
Mercur uses Algolia as a search engine to boost product search accuracy and serving trending/recommended items. The integration features auto product indexing, whenever any of the product attributes was changed or a new product review is created.Setup
In order to use Algolia, an account is needed. After registration, enterALGOLIA_APP_ID
and ALGOLIA_API_KEY
obtained from the Algolia dashboard into the .env
file.
Then, run the sync-algolia
script, in order to apply the default settings, and synchronize already existing products/reviews.
Run the following command from the apps/backend
catalog:
Configuration
The default configuration is present in theapps/backend/src/modules/algolia/service.ts
file. You can adjust the defaultProductSettings
and defaultReviewSettings
to your needs. That includes the searchable fields, facets, relevancy and ranking. See the full settings reference here. Default configuration includes only the searchable fields.
Events
In order to persist consistency between database and Algolia, every time any change in indexed entities happens an event is emitted, for example:algolia.products.changed
algolia.products.deleted
algolia.intermediate.fulfillment_set.changed
algolia.intermediate.service_zone.changed
algolia.intermediate.shipping_option.changed
algolia.intermediate.stock_location.changed
algolia.intermediate.inventory_item.changed