Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Algolia

Michael Solati edited this page Dec 2, 2021 · 4 revisions

Algolia provides search services for our team.

Indexing

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:

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).

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.

Search

The search side is implemented as a Web Component here. Its public keys are accessible inside that component.

Clone this wiki locally