Skip to content

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

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

feat(v2): contextual search, dynamic Algolia facetFilters#3550
slorber merged 10 commits intomasterfrom
slorber/contextual-search

Conversation

@slorber
Copy link
Collaborator

@slorber slorber commented Oct 7, 2020

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: algolia/docsearch-configs#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
Copy link
Contributor

docusaurus-bot commented Oct 7, 2020

Deploy preview for docusaurus-2 ready!

Built with commit c4abd5d

https://deploy-preview-3550--docusaurus-2.netlify.app

@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
Copy link
Collaborator Author

slorber commented Oct 15, 2020

Note

@slorber slorber deleted the slorber/contextual-search branch August 17, 2021 17:57
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