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 search results PAGE not returning any results #6693

Closed
4 of 7 tasks
yoavniran opened this issue Feb 16, 2022 · 34 comments
Closed
4 of 7 tasks

Algolia search results PAGE not returning any results #6693

yoavniran opened this issue Feb 16, 2022 · 34 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: duplicate This issue or pull request already exists in another issue or pull request

Comments

@yoavniran
Copy link

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

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:

Screen Shot 2022-02-16 at 14 29 57

However, when clicking the "see all results". The search page always shows NO results:

Screen Shot 2022-02-16 at 14 30 05

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

  1. open https://react-uploady.netlify.app
  2. use search modal to search for ex: "sender"
  3. see results
  4. scroll to bottom and click "see all X results"
  5. see page with no results

Expected behavior

Page should return all results

Actual behavior

no results are shown

Your environment

Reproducible demo

https://react-uploady.netlify.app

Self-service

  • I'd be willing to fix this bug myself.
@yoavniran yoavniran added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Feb 16, 2022
@Josh-Cena
Copy link
Collaborator

Duplicate of #5084, right?

@Josh-Cena Josh-Cena added closed: duplicate This issue or pull request already exists in another issue or pull request and removed status: needs triage This issue has not been triaged by maintainers labels Feb 16, 2022
@Josh-Cena
Copy link
Collaborator

Josh-Cena commented Feb 16, 2022

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.

That sounds like a distinct issue from the search modal sending incorrect requests, while we are only aware of the latter.

@yoavniran
Copy link
Author

thanks @Josh-Cena
Indeed duplicate (GH issue search sucks) and disheartening that its still open

  1. Is there no solution then for the search page yet? Or is the last comment something I can follow?
  2. 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

@Josh-Cena
Copy link
Collaborator

Josh-Cena commented Feb 16, 2022

/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.

@slorber
Copy link
Collaborator

slorber commented Feb 16, 2022

you added the search only 2 hours ago

image

Have you triggered a new crawl since enabling the search?

@yoavniran
Copy link
Author

@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
Copy link
Collaborator

slorber commented Feb 16, 2022

@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)

@shortcuts
Copy link
Contributor

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:

  1. Keep your search plugin enabled
  2. Enable contextualSearch
  3. Start a new crawl from the crawler interface https://crawler.algolia.com/
  4. 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

@Josh-Cena
Copy link
Collaborator

Okay! In that case, closing as duplicate of #5084. Hope we can get this fixed up soon...

@huynhicode
Copy link
Contributor

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

@shortcuts
Copy link
Contributor

Hey @huynhicode,

Are you using your own crawler our the Algolia Crawler?

The contextualSearch option requires a few things to work:

Feel free to provide more infos about your crawler/Algolia app, I'll check if the steps above doesn't help.

@yoavniran
Copy link
Author

thanks @shortcuts and @slorber, I can confirm the steps you described solved the issues. contextual works now on both modal & page 🔥

@huynhicode
Copy link
Contributor

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.

Screen Shot 2022-02-17 at 12 25 54 PM

@slorber
Copy link
Collaborator

slorber commented Feb 18, 2022

@huynhicode you can also trigger a crawl on a deploy preview or staging deployment if you need to reduce the risk

In #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

@huynhicode
Copy link
Contributor

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!

@huynhicode
Copy link
Contributor

We were able to get our modal and /search page working! 🎉

Thanks everyone for your help! @slorber @shortcuts

@elitan
Copy link

elitan commented Jun 17, 2022

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: nhost/nhost#716 and tried to follow the steps in this issue:

  1. Enabled contextualSearch (see PR above)
  2. Updated the Algolia crawler config:
  initialIndexSettings: {
    nhost: {
      attributesForFaceting: [
        "type",
        "lang",
        "language",
        "version",
        "docusaurus_tag",
      ],
      attributesToRetrieve: [
        "hierarchy",
        "content",
        "anchor",
        "url",
        "url_without_anchor",
        "type",
      ],
  1. 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?

@shortcuts
Copy link
Contributor

shortcuts commented Jun 17, 2022

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)

@slorber
Copy link
Collaborator

slorber commented Jun 17, 2022

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

CleanShot 2022-06-17 at 10 36 34@2x

CleanShot 2022-06-17 at 10 38 04@2x

@elitan
Copy link

elitan commented Jun 22, 2022

Thanks. I got it working. I did some permutation of steps. But in the end, I think these were the steps:

  1. Delete the current index (nhost).
  2. Copied the v2 config from https://docsearch.algolia.com/docs/templates/#docusaurus-v2-template. Updated with appName, apiKey, and index name (nhost).
  3. Re-run crawler (will create the index for me).
  4. Redeployed my Docusaurus site.

@kimsauce
Copy link

kimsauce commented Feb 22, 2023

Are you using your own crawler our the Algolia Crawler?

The contextualSearch option requires a few things to work:

Feel free to provide more infos about your crawler/Algolia app, I'll check if the steps above doesn't help.

@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. 🥳

@peterpeterparker
Copy link

Is the docusaurus v2 template still the one to use nowadays or should the v3 be used?

In any case, tried both. I used the template in Algolia, updated my keys and index name, double checked the tags docusaurus_tag, version and language, restarted an indexing but, nothing worked out.

Even worth, if I enable contextualSearch the all search does not work at all anymore.

Really confuse about what is the correct configuration 🤔.

@peterpeterparker
Copy link

peterpeterparker commented Jul 9, 2023

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.

Capture d’écran 2023-07-09 à 09 16 52

@slorber
Copy link
Collaborator

slorber commented Jul 19, 2023

Is the docusaurus v2 template still the one to use nowadays or should the v3 be used?

I recently asked the Algolia team for the creation of a v3 config, but for now, it's exactly the same as v2. It may start to diverge later.


the attributesForFaceting configuration in the index was actually not populated correctly

That's weird, we definitively this to be populated correctly for our search to work. Worth reporting a bug to the DocSearch team.

@nickzelei
Copy link

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: #6693 (comment)

@sr-remsha
Copy link

sr-remsha commented Jan 12, 2024

I use Docusaurus V3.

  1. I used crawler config from here
  2. In docusaurus config I have contextualSearch: true,
  3. In index config in Filtering and Faceting I added Facets docusaurus_tag, edition, lang, language, type and version

Only after step 3 it started working: both modal and full page

Previously, I had contextualSearch: false and only the modal worked.

@easystartup-io
Copy link

easystartup-io commented Jan 24, 2024

Yes faced similar issue. I use V3 and my algolia docsearch got approved today. I was first facing issue

  1. Had to use crawler config from v3 template
  2. In docusaurus config I have contextualSearch: true my config
  3. Delete existing index and retrigger crawling
  4. Now both search and modal works perfectly fine.

ignoreCanonicalTo: true in the crawler config is critical else pages were getting ignored.

My website for reference https://k3s-simplified.easystartup.io/

@slorber
Copy link
Collaborator

slorber commented Apr 5, 2024

No search result?

For anyone passing by, if you don't get any Algolia search results:

  • make sure that your Algolia index has the fields in the screenshot below
  • If you don't see these fields, then you have an index config problem
  • You should check your crawler config, make sure it matches the recommended one, and then delete/recreate your index based on the newly updated/fixed crawler config (Algolia team recommendation)

image

See also: #10007 (comment)

radist2s added a commit to OpenAPI-Qraft/openapi-qraft that referenced this issue Apr 11, 2024
radist2s added a commit to OpenAPI-Qraft/openapi-qraft that referenced this issue Apr 11, 2024
@randombeeper
Copy link

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

@slorber
Copy link
Collaborator

slorber commented Apr 24, 2024

Thanks @randombeeper

we have recently added some docs here, let me know if this looks good:
#10056
https://docusaurus.io/docs/search#algolia-troubleshooting

@ncoughlin
Copy link
Contributor

Respectfully 🙏 I think that all of the troubleshooting comments here are off the mark.

If I set contextualSearch: false in my docusaurus config file, I expect that to apply to both the search modal and the search page.

Every solution on this page is based on the pretext of ignoring this error and forcing users to configure their index for use contextual search, as though this is somehow easier than making the search page respect the config settings and send the same request format as the modal.

If the intention is to force all users to configure and use contextual search (even if it is not necessary for their use case), then the contextualSearch option should be removed from the config file and documentation.

If the intention is to allow users to disable contextual search, then the search page should be updated to respect the config file.

It seems that all the advice here is simply a very complicated workaround to what should be a simple solution.

Make the search page respect the contextualSearch config and send the same request that the modal does.

@slorber
Copy link
Collaborator

slorber commented May 20, 2024

If the intention is to allow users to disable contextual search, then the search page should be updated to respect the config file.

The problem is tracked here: #3805

The only reason the search page does not respect the config is because we maintainers have limited time. Fixing it requires a quite significant refactor of some very old legacy code (pre 2020, not even written by me). And the ROI is limited considering this page is not widely used.

If anyone wants to contribute a fix to the search page, PRs are welcome. Unfortunately I can't make it a priority right now, but we'll come to it someday.

@novalagung
Copy link

I experienced the same issue today, it was happening on one of my sites. It's kind of weird because my other 3 sites use Algolia DocSearch too and it works smoothly right after initial setup.

@peterpeterparker's solution works fine. I managed to resolve this issue by simply adding the docusaurus_tag under attributesForFaceting. Just it, no additional steps are needed on either Algolia's website or docusaurus config file.

image

@ncoughlin
Copy link
Contributor

This issue was resolved in a pull request 4 days ago and should be included in the version 3.4 update. What version of Docusaurus do you have?

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 closed: duplicate This issue or pull request already exists in another issue or pull request
Projects
None yet
Development

No branches or pull requests