Skip to content

Algolia Contextual Search Generates Incorrect FaceFilters #10050

@karl-cardenas-coding

Description

@karl-cardenas-coding

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

When experimenting with the Algolia Crawler, I noticed that when contextual search is enabled no results are returned. The API requests are successful (status code 200), but no hits are returned.

I stumbled upon this Aloglia support thread trying to understand what might be causing the issue.

Upon closer investigation I noticed how the facetFilter parameter generated by Docusarus is incorrect compared to what Algolia expects.

The Crawler’s search UI includes the following values in the searchFacets query when I enable some custom facets such as as docusaurus_tag , version, and language.

[["docusaurus_tag:docs-default-4.3.x"],["version:4.3.x"],["lang:en"]]"}]}

This returns results as expected.

Now, in Docusarus, when contextual search in enabled, here is what is provided in the API request.

 ["language:en",["docusaurus_tag:default","docusaurus_tag:docs-default-current","docusaurus_tag:docs-api-current"]]"}]}

The list value is not generated correctly.

If I re-create the API post request with this vale for the faceFilter, I get the expected results.

facetFilters=[["docusaurus_tag:docs-default-4.3.x"],["version:4.3.x"],["lang:en"]]"}]}

Reproducible demo

No response

Steps to reproduce

You can use this codebox URL.

But or spin up a quick Docusarus project and use my Algolia config or the one included in the Algolia issue.

Expected behavior

The expected behavior is to return the expected results using the facefilter Docusarus includes in the post request.

Actual behavior

No results are returned.

Your environment

  • Public source code.
  • Public site URL: https://docs.spectrocloud.com
  • Docusaurus version used: 3.2.1
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Node.js 18, Chrome 123.0.6312.123
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): MacOS 14.4.1 (23E224)

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executionclosed: working as intendedThis issue is intended behavior, there's no need to take any action.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions