Algolia search results PAGE not returning any results
Have you read the Contributing Guidelines on issues?
- [X] I have read the Contributing Guidelines on issues.
Prerequisites
- [X] I'm using the latest version of Docusaurus.
- [X] I have tried the
npm run clearoryarn clearcommand. - [X] I have tried
rm -rf node_modules yarn.lock package-lock.jsonand 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
I enabled algolia search on my site: https://react-uploady.netlify.app
The modal works fine and returns results for existing search terms.
For example:
However, when clicking the "see all results". The search page always shows NO results:
I noticed that when contextualSearch was enabled, I also got no results in the modal. When I set it to false the results started showing.
I think there are values being sent from the page that arent being sent from the modal.
This is the query data from the modal:
{"requests":[{"query":"provider","indexName":"react-uploady","params":"attributesToRetrieve: ["hierarchy.lvl0","hierarchy.lvl1","hierarchy.lvl2","hierarchy.lvl3","hierarchy.lvl4","hierarchy.lvl5","hierarchy.lvl6","content","type","url"]
attributesToSnippet: ["hierarchy.lvl1:10","hierarchy.lvl2:10","hierarchy.lvl3:10","hierarchy.lvl4:10","hierarchy.lvl5:10","hierarchy.lvl6:10","content:10"]
snippetEllipsisText: β¦
highlightPreTag: <mark>
highlightPostTag: </mark>
hitsPerPage: 20
facetFilters: []"}]}
While this is the query from the page:
{"requests":[{"indexName":"react-uploady","params":"hitsPerPage: 15
advancedSyntax: true
query: provider
page: 0
facets: ["language","docusaurus_tag"]
tagFilters:
facetFilters: [["language:en"],["docusaurus_tag:default","docusaurus_tag:docs-default-current"]]"},{"indexName":"react-uploady","params":"hitsPerPage=1
advancedSyntax: true
query: provider
page: 0
attributesToRetrieve: []
attributesToHighlight: []
attributesToSnippet: []
tagFilters:
analytics: false
clickAnalytics: false
facets: language
facetFilters: [["docusaurus_tag:default","docusaurus_tag:docs-default-current"]]"},{"indexName":"react-uploady","params":"hitsPerPage=1
advancedSyntax: true
query: provider
page: 0
attributesToRetrieve: []
attributesToHighlight: []
attributesToSnippet: []
tagFilters:
analytics: false
clickAnalytics: false
facets: docusaurus_tag
facetFilters: [["language:en"]]"}]}
Steps to reproduce
- open https://react-uploady.netlify.app
- use search modal to search for ex: "sender"
- see results
- scroll to bottom and click "see all X results"
- see page with no results
Expected behavior
Page should return all results
Actual behavior
no results are shown
Your environment
- Public source code: https://github.com/rpldy/react-uploady-docs
- Public site URL: https://react-uploady.netlify.app
- Docusaurus version used: 2.0.0-beta.15
Reproducible demo
https://react-uploady.netlify.app
Self-service
- [ ] I'd be willing to fix this bug myself.
Duplicate of #5084, right?
I noticed that when
contextualSearchwas enabled, I also got no results in the modal. When I set it tofalsethe results started showing.
That sounds like a distinct issue from the search modal sending incorrect requests, while we are only aware of the latter.
thanks @Josh-Cena Indeed duplicate (GH issue search sucks) and disheartening that its still open
- Is there no solution then for the search page yet? Or is the last comment something I can follow?
- Yes, the contextualSearch param does seem to break the search. Thats what made me think to look at the params being sent from the search page
/cc @lex111 We may need to revamp the search page, now that you are already working on #6692.
We'll keep it open because of that contextualSearch issue. cc @shortcuts as well, if we can get any input on your side.
Since I'm not familiar with Algolia at all, not much input on my sideπ€·ββοΈ
Indeed duplicate (GH issue search sucks)
The in:title query is your friend, especially if you want to navigate around larger repositories like the TypeScript repo with 5000+ issues. #5084 is not very easy to find because it's not searchable through search page in:title, but it is through algolia request in:title, since you already realized it has something to do with the request shape.
you added the search only 2 hours ago
Have you triggered a new crawl since enabling the search?
@slorber Search works in the modal consistently. This also seems to be the same issue reported in #5084 Are you suggesting that for the same term working in modal, not working in page, can be related to crawling?
@slorber Search works in the modal consistently.
You said they do not show if you turn contextualSearch on.
Yes, you have to follow the doc and trigger a crawl or wait 24h. If contextual search doesn't work, then you have a deeper problem because the search page somehow always use contextual search (we'll change that)
Hey,
As @slorber said, the issue is that the search plugin was not enabled before crawling your website, which make contextualSearch unusable.
To solve your issue:
- Keep your search plugin enabled
- Enable
contextualSearch - Start a new crawl from the crawler interface https://crawler.algolia.com/
- Enjoy searching from both the modal and the search page :D
because the search page somehow always use contextual search (we'll change that)
It would indeed be nice to make it follow the config value
Okay! In that case, closing as duplicate of #5084. Hope we can get this fixed up soon...
I know this issue is closed as it is a duplicate of #5084, but I wanted to chime in here and say that I am also experiencing the same issues as outlined above.
The modal search will only return results if contextualSearch is set to false. The /search page does not return any results.
I have tried to debug this issue according to the suggestions from the Discord servers for Algolia DocSearch and Docusaurus, and so far nothing has worked for me.
I am hoping there is a fix soon, thank you. π
@Josh-Cena @shortcuts
Hey @huynhicode,
Are you using your own crawler our the Algolia Crawler?
The contextualSearch option requires a few things to work:
- Having
docusaurus_tag,versionandlanguagein theattributesForFaceting(see Docusaurus v2 config template) - The steps describe in https://github.com/facebook/docusaurus/issues/6693#issuecomment-1041545752
Feel free to provide more infos about your crawler/Algolia app, I'll check if the steps above doesn't help.
thanks @shortcuts and @slorber, I can confirm the steps you described solved the issues. contextual works now on both modal & page π₯
Thanks @shortcuts, we have this set as the configuration for attributesForFaceting.
Currently, the code exists on a local branch. I am hesitant to push code that is not working locally, but it seems like the crawler needs to crawl a public URL with the Algolia search code.

@huynhicode you can also trigger a crawl on a deploy preview or staging deployment if you need to reduce the risk
In https://github.com/facebook/docusaurus/pull/6707 I change this behavior for next release: your index should contain correct Algolia metadata in all cases (after a crawl of course) even if your site in production doesn't have the Algolia plugin/config activated. Hopefully this will help reduce this confusion
Thank you @slorber
We will deploy our code to staging to test. Will reach back out if we encounter further issues.
Appreciate all the help!
We were able to get our modal and /search page working! π
Thanks everyone for your help! @slorber @shortcuts
I have the same issue. Our search is working in the dialog but not on the full page.
I'm working on a fix here: https://github.com/nhost/nhost/pull/716 and tried to follow the steps in this issue:
- Enabled
contextualSearch(see PR above) - Updated the Algolia crawler config:
initialIndexSettings: {
nhost: {
attributesForFaceting: [
"type",
"lang",
"language",
"version",
"docusaurus_tag",
],
attributesToRetrieve: [
"hierarchy",
"content",
"anchor",
"url",
"url_without_anchor",
"type",
],
- Deployed a preview environment: https://docs-git-docs-algolio-fix-nhost.vercel.app/
Result: Search stopped working in the modal. The full-page search still does not work.
Could someone hint me in the right direction to fix this?
Hey @elitan, initialIndexSettings are applied at index creation time only, so you might need to delete your index from the Algolia dashboard (https://www.algolia.com/apps/YOUR_APP_ID/dashboard) and restart a crawl, everything should work after this.
Was your config deploy without the Docusaurus v2 default template? Or have you migrated to Docusaurus v2 after the DocSearch instance have been deployed? (Checking if the issue come from our deploy process)
Note: contextual search is enabled by default now.
In Docusaurus v1, or in older versions of Docusaurus v2, there was no "attributesForFaceting. docusaurus_tag" in the crawler config. This lead to contextual search not working.
You can see contextual search is not working if:
- the /search page is not working (always)
- the modal search is not working with contextualSearch: true, but works with contextualSearch: false
That looks to be the case here, so you'll need to fix the Crawler, and ensure Docusaurus can filter on the "docusaurus_tag" field (metadata that we put in your pages for filtering).
If you can't see "docusaurus_tag" anywhere in the Algolia dashboard, that's a sign that your index probably has a bad configuration


Thanks. I got it working. I did some permutation of steps. But in the end, I think these were the steps:
- Delete the current index (
nhost). - Copied the v2 config from https://docsearch.algolia.com/docs/templates/#docusaurus-v2-template. Updated with
appName,apiKey, and index name (nhost). - Re-run crawler (will create the index for me).
- Redeployed my Docusaurus site.