docusaurus: Algolia search results PAGE not returning any results
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I’m using the latest version of Docusaurus.
- I have tried the
npm run clear
oryarn 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
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.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 30 (7 by maintainers)
Commits related to this issue
- chore(website): update algolia custom crawler `attributesForFaceting` config to keep `algolia.contextualSearch` intact * See: https://github.com/facebook/docusaurus/issues/6693#issuecomment-104271855... — committed to OpenAPI-Qraft/openapi-qraft by radist2s 3 months ago
- chore(website): update algolia custom crawler `attributesForFaceting` config to keep `algolia.contextualSearch` intact * See: https://github.com/facebook/docusaurus/issues/6693#issuecomment-104271855... — committed to OpenAPI-Qraft/openapi-qraft by radist2s 3 months ago
Finally, I was able to solve it! Even though I followed exactly the steps provided by @elitan in this answer, including deleting the index, using the template v2, reindexing, enabling
contextualSearch
, and redeploying, the problem persisted.Eventually, I realized that despite these steps and the presence of the fields in my crawler settings, the
attributesForFaceting
configuration in the index was actually not populated correctly (🤷♂️). So, I manually added the required fields in the UI and initiated a reindexing, which ultimately resolved the issue.Thanks. I got it working. I did some permutation of steps. But in the end, I think these were the steps:
nhost
).appName
,apiKey
, and index name (nhost
).We were able to get our modal and /search page working! 🎉
Thanks everyone for your help! @slorber @shortcuts
@shortcuts @slorber Oh my goodness, thank you both so much for this fix! I was facing the same issues as the others here and stumbled upon this thread. Both my modal and search page are working now. 🥳
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:
contextualSearch
It would indeed be nice to make it follow the config value
No search result?
For anyone passing by, if you don’t get any Algolia search results:
See also: https://github.com/facebook/docusaurus/discussions/10007#discussioncomment-9021352
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:
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
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)
thanks @shortcuts and @slorber, I can confirm the steps you described solved the issues. contextual works now on both modal & page 🔥
Hey @huynhicode,
Are you using your own crawler our the Algolia Crawler?
The
contextualSearch
option requires a few things to work:docusaurus_tag
,version
andlanguage
in theattributesForFaceting
(see Docusaurus v2 config template)Feel free to provide more infos about your crawler/Algolia app, I’ll check if the steps above doesn’t help.
Hi everyone, James from Algolia chiming in since this is a regular question and this issue is regularly referenced.
The first time the crawler runs, the initialIndexSettings in the crawler configuration file will be used but on subsequent runs it will not be, thus the name. If you want to change the index settings, delete the index with the name specified under initialIndexSettings. The next time the crawler runs the attributes will be populated and then the facetFilters being used by Docusaurus will match up.
Algolia has a discord channel dedicated to DocSearch, come join us there if you have more questions: Discord
Yes faced similar issue. I use V3 and my algolia docsearch got approved today. I was first facing issue
ignoreCanonicalTo: true
in the crawler config is critical else pages were getting ignored.My website for reference https://k3s-simplified.easystartup.io/
Following the comments here was able to get this to work after updating my Crawler to use the v3 config. I applied for the open source program so the crawler was created for me with the wrong config settings.
I updated it based on their site to use the v3 config but still ran into issues. The problem I had was I was initializing the index myself and letting the crawler fill it.
The fix was to let the crawler create the index for me because there are settings it fills only on initial creation. I found that by re-reading thru this issue and found this comment: https://github.com/facebook/docusaurus/issues/6693#issuecomment-1158568333
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:
contextualSearch
(see PR above)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?
@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?
/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🤷♂️
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 throughsearch page in:title
, but it is throughalgolia request in:title
, since you already realized it has something to do with the request shape.