Skip to content

feat(v2): contextual search, dynamic Algolia facetFilters - #3550

Merged
slorber merged 10 commits into
masterfrom
slorber/contextual-search
Oct 15, 2020
Merged

slorber merged 10 commits into
masterfrom
slorber/contextual-search

Conversation

@slorber

@slorber slorber commented Oct 7, 2020 •

Copy link
Copy Markdown
Collaborator

Motivation

Algolia search engine should create its filter dynamically according to the browsed page, instead of hardcoding the facetFilters in config file.

See also #3396

In practice, this allows:

  • to search in the version you are currently browsing (so the filter query adapts to the current page)
  • to search in standalone pages and blog posts (not possible before)
  • to search in sites with multiple docs plugins (we have 2 "docs" and "community" on Docusaurus)

Design choice: make the page tagging system decoupled from Algolia, so that maybe we could support another search engine plugin in the future ( like docusaurus-theme-search-elastic) or enable the community to provide its own search system, and still be able to use the contextual search feature.

Enable contextual search

Documentation: https://deploy-preview-3550--docusaurus-2.netlify.app/classic/docs/search#contextual-search

The contextualSearch is for now opt-in, for retrocompatibility.

Algolia crawler should run on your upgraded site, so you'd rather turn this on in 2 phases (ie not upgrade + contextualSearch: true in the same PR/commit). You should rather get this working locally before publishing a site with contextualSearch: true.

If it does not work, check that the Algolia DocSearch team has added the docusaurus_tag value in your config attributesForFaceting , like here: https://github.com/algolia/docsearch-configs/pull/2546

Note: the Algolia team should normally add this to your config automatically before the 23 October, in the meantime you can submit a PR to your own config.

Breaking change:

  • the facet version:latest has been removed, as it was introduced recently, was not widely used, and is a bit hacky

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Preview + dogfooding + tests

@slorber
slorber requested a review from lex111 as a code owner October 7, 2020 18:24
@slorber
slorber marked this pull request as draft October 7, 2020 18:24
@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Oct 7, 2020
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Oct 7, 2020
@slorber slorber linked an issue Oct 7, 2020 that may be closed by this pull request
@docusaurus-bot

docusaurus-bot commented Oct 7, 2020 •

Copy link
Copy Markdown
Contributor

@slorber
slorber marked this pull request as ready for review October 13, 2020 18:21
@slorber slorber added the pr: breaking change Existing sites may not build successfully in the new version. Description contains more details. label Oct 14, 2020
@slorber slorber changed the title feat(v2): contextual search feat(v2): contextual search, dynamic Algolia facetFilters Oct 14, 2020
slorber added a commit to slorber/docsearch-configs that referenced this pull request Oct 15, 2020
@slorber
slorber merged commit 21264f5 into master Oct 15, 2020
@slorber

slorber commented Oct 15, 2020

Copy link
Copy Markdown
Collaborator Author

Note

@slorber
slorber deleted the slorber/contextual-search branch August 17, 2021 17:57
mrizwanashiq pushed a commit to mrizwanashiq/docusaurus that referenced this pull request Jun 25, 2026
* POC of contextual search dynamic filters

* fix useSearchTags bugs

* contextual search should use preferred version  (persisted in storage)

* Contextual search: make system decoupled from algolia + wire proper meta tags and facet filters

* rework doc tag + minor refactorings

* update snapshots

* polish contextual search

* add Algolia validateThemeConfig tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: breaking change Existing sites may not build successfully in the new version. Description contains more details. pr: new feature This PR adds a new API or behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Contextual doc version search (Algolia/DocSearch)

3 participants