Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support facet filters for docsearch #3026

Merged

Conversation

beckerjohannes
Copy link
Contributor

Purpose

Extend the configuration parameters of docsearch to support facets.

Docsearch has something called 'facets' where you can restrict the results based on record attributes in the indexed results. E.g. if the crawler extracts version information from your pages you can restrict search results to latest. See

https://docsearch.algolia.com/docs/docsearch-v3/#filtering-your-search

Fixes #3022

Documentation

https://bootstrap.hugoblox.com/hugo-tutorials/search/#docsearch

features:
  search:
    provider: docsearch
    docsearch:
      app_id: 'PASTE ID'
      api_key: 'PASTE KEY'
      index_name: 'PASTE INDEX NAME'
      # Optional search parameters, currently only facetFilters supported.
      search_parameters:
        facetFilters: 
          - '<ATTRIBUTE-NAME>:<VALUE>'
          - '<ATTRIBUTE-NAME>:<VALUE>'

If you like to limit the results of your search to specific topics, you can define facetFilters based on the attributes indexed by the algolia crawler. This is useful to limit search results for example to specific language or a specific version (e.g. version:latest). Details on the required docsearch configuration can be found here.

Adding DocSearch meta tags can be added to your site by creating a customized head-end hook based on page frontmatter.

<meta name="docsearch:language" content="en">
<meta name="docsearch:date" content="{{ .Date.UTC.Unix | safeHTML }}">
<meta name="docsearch:lastmod" content="{{ .Lastmod.UTC.Unix | safeHTML }}">
<meta name="docsearch:version" content=".Params.version">

Copy link

netlify bot commented Nov 27, 2023

Deploy Preview for academic-demo canceled.

Name Link
🔨 Latest commit 7130df3
🔍 Latest deploy log https://app.netlify.com/sites/academic-demo/deploys/6564ad67b83a170008b03051

@gcushen gcushen merged commit c57e12d into HugoBlox:main Nov 27, 2023
8 checks passed
@gcushen
Copy link
Collaborator

gcushen commented Nov 27, 2023

@beckerjohannes thanks for contributing to the open source movement :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Facet Filtering for DOCSEARCH
2 participants