# Algolia Search Implementation Onboarding Doc ## Introduction This document serves as a general introduction to adding a search bar feature into our documentation websites that were built using Docusaurus. This work was previously done in Taquito in [this PR](https://github.com/ecadlabs/taquito/pull/1290/files#diff-bc4913d026ae51bef2bc8b7a1c040fdf52b999d99e6fa40d87b379f98a60e0ea) The search component integration is split into 2 parts for our purpose: - Search bar UI - Site indexer (Algolia) ## Implementation ### Search Bar UI The search bar will show automatically when a Docusaurus config is enabled, namely the `algolia` property. See [docusaurus config](https://github.com/ecadlabs/taquito/blob/master/website/docusaurus.config.js#L171) It is also important to install the related NPM dependencies: - https://github.com/ecadlabs/taquito/blob/master/website/package.json#L24 - https://github.com/ecadlabs/taquito/blob/master/website/package.json#L46 ### Search Indexing The search indexing part of the flow has a few nuanced steps to note that we'll go over in this section. But before that, it's also important to acknowledge that this approach is subject to improvement, and it was the best possible solution at the time given the limitations of Algolia search. With continued improvements from the Docusaurus team, we might reach a state where a simpler solution would exist. #### The 'Free' Approach Algolia provides a discounted/free tier for documentation websites of open source projects (see https://www.algolia.com/for-open-source/). Technically Taquito would qualify at the time, but for some reason we were rejected and so we opted for a more independent solution to run _their_ indexer on our CI builds instead. If the Taqueria team wants to, it could probably push for this approach. But there are pluses and minuses to having them index our website for us. Pros: - Headache free approach - One less thing to maintain and build - No extra CI build for indexing Cons: - We are dependant on their indexing to work well - No granular control over what gets indexed and what doesn't - Might take a bit of a back and forth and re-appealing until we get approved #### The 'Paid' Approach This is the current approach we are using in Taquito. Algolia provides a Docker container that we can run to help us index things locally (or in CI), ad hoc. In short, we need to initialize the project in the Algolia dashboard, grab environment variables and pass them into the Docker container so that it may run the indexer at a specific website build/domain, and will then store the indexed entries at our dashboard. The indexed entries are mapped to our website pages and will intelligently return relevant pages to the search term. A config file will also need to be passed into it (see https://github.com/ecadlabs/taquito/blob/master/website/config.json) The search bar will then make calls to the Algolia project we initialized, making our website searchable. Here are some links to help with integrating the search indexer/component to a Docusaurus website. - Running your own Algolia indexer https://docsearch.algolia.com/docs/legacy/run-your-own/ - Creating your index in the Algolia dashboard https://www.algolia.com/apps/CMVCSQI8D6/explorer/browse/taquito?page=1&searchMode=search (Please DM Davis or Jev for access) - Example Github workflow that we have in Taquito https://github.com/ecadlabs/taquito/blob/master/.github/workflows/algolia.yml Pros: - Granular control over what gets indexed or not, and indexing interval (every x days) - Self-sufficient solution; not dependent on a 3rd party to index our website Cons: - After a certain amount of entries, we need to pay a fee to store indexes - A bit more extra work and maintenance