Open
Description
🐛 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
Activity
ayshiff commentedon Nov 25, 2020
@slorber Can I work on this ?
slorber commentedon 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"]
todisjunctiveFacets: ['customTag']
andalgoliaHelper.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:
feat: enable docsearch
feat: enable docsearch
TomPeirs commentedon Jun 22, 2021
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 commentedon Jul 1, 2021
My site is a single language project in Chinese. With
contextualSearch
set tofalse
I still have the similar issue thatlanguage
option is always passed tofacetFilters
in SearchPage which causes it does not return any result.slorber commentedon 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 commentedon 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 commentedon Jul 2, 2021
The algolia theme is well installed on your site, and it has correct metadatas:
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.
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 commentedon Jul 2, 2021
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
17 remaining items