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

Algolia plugin SearchPage does not respect configuration #3805

Open
slorber opened this issue Nov 23, 2020 · 15 comments
Open

Algolia plugin SearchPage does not respect configuration #3805

slorber opened this issue Nov 23, 2020 · 15 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution domain: search Related to the search feature, usually Algolia

Comments

@slorber
Copy link
Collaborator

slorber commented Nov 23, 2020

🐛 Bug Report

Use some algolia config like:

    algolia: {
      apiKey: '47ecd3b21be71c5822571b9f59e52544',
      indexName: 'docusaurus-2',
      contextualSearch: true,
      searchParameters: {facetFilters: ['bad:filter']},
    },

Due to the presence of bad:filter, it should actually never find any result.

But the current search page does not respect the plugin configuration options.

We should rather make the search page results consistent with the navbar search input / modal results, and use the plugin options.

Edit: if contextual search is not enable, we should not append any facet filter to the query by default, to prevent issues such as #4644

@slorber slorber added the bug An error in the Docusaurus core causing instability or issues with its execution label Nov 23, 2020
@ayshiff
Copy link
Contributor

ayshiff commented Nov 25, 2020

@slorber Can I work on this ?

@slorber
Copy link
Collaborator Author

slorber commented Nov 25, 2020

yes @ayshiff thanks, but let's first see how complex it might be

Note, some users want to use both contextual search + additional facetFilters at the same time (#3804)

@Shipow @francoischalifour the Algolia API we use for that search page looks different than the one we use for the Navbar input/dropdown (DocSearch), wonder if you know how we could make this more consistent, and also use docsearch apis on the search page instead of algoliasearch/lite and algoliasearch-helpers?

It looks to me that the algolia site config we have is DocSearch props, but for the search page, we would have to convert searchParameters.facetFilters = ["customTag:value"] to disjunctiveFacets: ['customTag'] and algoliaHelper.addDisjunctiveFacetRefinement("customTag:value"), and it may not be very convenient to write this conversion logic. Wonder if we could use the same DocSearch props against both the dropdown, and an imperative search api.

Files:

molant added a commit to electron/website that referenced this issue May 3, 2021
Enable docsearch module with provided configuration by algolia.

Currently the search does not seem to work when `contextSearch` is
enabled. This seems to be a temporary issue per Clement's mail:

> As the DocSearch plugin is not active yet, you won't be able to use
the Docusaurus `contextualSearch` option until next crawl.

While this feature is not necessary (there are no versioned docs),
it seems like the search results page has it enabled by default
always ([1]) so might as well have it enabled everywhere to make sure it
works.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

[1]: https://github.com/temporalio/documentation/pull/357/files#r616656533
Ref: facebook/docusaurus#3805
Part of #2
molant added a commit to electron/website that referenced this issue May 5, 2021
Enable docsearch module with provided configuration by algolia.

Currently the search does not seem to work when `contextSearch` is
enabled. This seems to be a temporary issue per Clement's mail:

> As the DocSearch plugin is not active yet, you won't be able to use
the Docusaurus `contextualSearch` option until next crawl.

While this feature is not necessary (there are no versioned docs),
it seems like the search results page has it enabled by default
always ([1]) so might as well have it enabled everywhere to make sure it
works.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

[1]: https://github.com/temporalio/documentation/pull/357/files#r616656533
Ref: facebook/docusaurus#3805
Part of #2
Close #22
@TomPeirs
Copy link

Note, some users want to use both contextual search + additional facetFilters at the same time (#3804)

Exactly, we are one of those users.

Still relevant in Alpha.75 -> https://docs.boc-group.com/adonis/en/
When I search for "API" the modal search box returns proper results. But the SearchPage does not respect our facetfilter.

@sparanoid
Copy link
Contributor

sparanoid commented Jul 1, 2021

My site is a single language project in Chinese. With contextualSearch set to false I still have the similar issue that language option is always passed to facetFilters in SearchPage which causes it does not return any result.

@slorber
Copy link
Collaborator Author

slorber commented Jul 1, 2021

The Search Page does not respect contextualSearch: false either and always use facet filters for querying.

But it should still work, unless your Algolia index config is not up-to-date or it didn't crawl your site yet with the algolia plugin enabled. If your site is correctly configured (which I can't verify without seeing the conf and live URL), filtering on language should work.

@sparanoid
Copy link
Contributor

sparanoid commented Jul 2, 2021

@slorber Thanks for explaining. I'm using docusaurus-2.json and self-hosted scraper with Docker. You can see the live demo here: https://openbayes-docs.pages.dev/docs

@slorber
Copy link
Collaborator Author

slorber commented Jul 2, 2021

The algolia theme is well installed on your site, and it has correct metadatas:

<meta data-react-helmet="true" name="docsearch:docusaurus_tag" content="docs-default-current"

The config looks fine, but you probably have to set your own site's start URL so that it crawls your site instead of the Docusaurus site.

  "index_name": "docusaurus-2",
  "start_urls": [
    "https://docusaurus.io/"
  ],
  "sitemap_urls": [
    "https://docusaurus.io/sitemap.xml"
  ],

However, I'm surprised it does not work only in the search page.

Also, if the modal does not work for contextualSearch: true, that is likely to hide some potential problem and the fields we query on are not indexed correctly.

@shortcuts any idea what could be going on? I'm not very familiar with the self-hosted scraper

@sparanoid
Copy link
Contributor

I re-scrap our site with the start_urls matched to our master branch deployment (I just updated the URL in previous comment) and now everthing seems working.

An unrelated issue I found is when typing something in the input it loses focus eveytime. But this is not reproducible on https://docusaurus.io/search

@slorber
Copy link
Collaborator Author

slorber commented Jul 5, 2021

Great that the recrawl fixed it.
The other issue you mention is already fixed on master and will be in beta.4 (#5100) but you can use canary if you want: https://docusaurus.io/community/canary

@peirstom
Copy link

peirstom commented Jul 7, 2022

Hi, any update on this ticket?

@jsphstls
Copy link

This continues to affect Docusaurus instances by creating an unexpected difference in behavior between the search bar and the search page. The solution was already discussed. What does this issue need to move forward?

@imroc
Copy link

imroc commented Oct 14, 2023

Still not fixed after 3 years?

@deepaksood619
Copy link

Still not fixed

@antoinetissier
Copy link

antoinetissier commented Apr 3, 2024

Hello, this is an issue in our project as well: we have custom facet filters that are required for the search to work properly, but they are not included in the query sent by the search page, so it consistently yields no results.

This looks especially bad when the user ends up on the search page as a result of clicking the "See all x results" link from the bottom of the search results dropdown.

Is there any chance that this issue is fixed in the near feature ?
In the meantime, are there workarounds ? In particular I was thinking of maybe swizzling the SearchPage component, but it sounds a bit hacky and so feedback is welcome before getting into it.

Thanks a lot !

@slorber
Copy link
Collaborator Author

slorber commented Apr 4, 2024

This issue is unfortunately not a top priority for me right now. If someone from the community wants to work on it I'd be happy to review their PR but I can't work on it myself in the near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution domain: search Related to the search feature, usually Algolia
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants