-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Algolia
Algolia provides search services for our team.
We take the 11ty collection , collections.all
, which gets parsed by some filters to a helper JSON file at "pages.json" (built here).
After 11ty runs, we index based on that file as part of deploy. The script which does that uses the generated file by:
- Set searchable attributes for Algolia.
That way we don't end up searching things like the URL or image of a page (all image URLs have
web-dev
in them, so searching "web" can pull up any post).
- Set a custom ranking field for Algolia.
This let's us prioritize certain pages, such as learning paths, and de-prioritize others, such as
/tags
,/authors
, etc...
- Define a new indexed date.
Used to determine which content has not been updated and therefore doesn't exist anymore.
- Add new indexed date to all entries.
- Index all new pages.
- Remove any items that were indexed prior to that date.
Algolia is intentionally very unstructured.
It just indexes JSON objects keyed by an objectID
field, which in our case, is the MD5 hash of the page's URL.
Every other field is indexed somewhat generically—Algolia doesn't care whether it's a number, full-text, a Date, etc.
The search side is implemented as a Web Component here. Its public keys are accessible inside that component.