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: Cannot read property 'lvl0' of undefined #336

Closed
3 tasks done
martinszeltins opened this issue Jul 19, 2021 · 7 comments
Closed
3 tasks done

Algolia search: Cannot read property 'lvl0' of undefined #336

martinszeltins opened this issue Jul 19, 2021 · 7 comments
Labels
need more info Further information is requested

Comments

@martinszeltins
Copy link

Describe the bug

When using Algolia search I'm getting this error in console and the search results do not appear. The API key is correct because the search results do appear when looking at XHR request.

Uncaught (in promise) TypeError: Cannot read property 'lvl0' of undefined
    at DocSearchModal.js:187
    at groupBy.js:3
    at Array.reduce (<anonymous>)
    at Vn (groupBy.js:2)
    at DocSearchModal.js:186

Reproduction

I just installed a new vitepress app, added my Algolia API key and App Id and this error occurred

My config.js

module.exports = {
    themeConfig: {
        sidebar: 'auto',
        algolia: {
            apiKey: '45d2386d18e39ac011227993d8353c00',
            appId: 'H5ZNGVTVMT',
            indexName: 'program_docs'
        }
    }
}

Expected behavior

I expected to see the results appear in Algolia search box

System Info

npx: installed 1 in 0.707s

  System:
    OS: Linux 5.8 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
    Memory: 12.12 GB / 31.08 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 14.17.2 - /usr/bin/node
    npm: 6.14.13 - /usr/bin/npm
  Browsers:
    Chrome: 91.0.4472.164
    Firefox: 90.0
  npmPackages:
    vitepress: ^0.15.6 => 0.15.6

Additional context

No response

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@martinszeltins martinszeltins added the bug: pending triage Maybe a bug, waiting for confirmation label Jul 19, 2021
@succeedium
Copy link

+1
I encountered exactly the same issue

@wkl007
Copy link

wkl007 commented Oct 20, 2021

I have the same issue

@kiaking
Copy link
Member

kiaking commented May 23, 2022

Can someone confirm this on next-theme branch? I'm not having issues with Vue related sites.

@kiaking kiaking added need more info Further information is requested and removed bug: pending triage Maybe a bug, waiting for confirmation labels May 23, 2022
@veryard
Copy link
Contributor

veryard commented May 28, 2022

Can someone confirm this on next-theme branch? I'm not having issues with Vue related sites.

I have had a quick play around with this and the new theme looks awesome 👍

When using the normal Algolia crawler instead of the DocSearch one I get this error. Example when using the Netlify DocSearch Plugin which sets up the crawler for you. The searchableAttributes do not match that of what the DocSearchModal.js requests.

attributesToRetrieve: ['hierarchy.lvl0', 'hierarchy.lvl1', 'hierarchy.lvl2', 'hierarchy.lvl3', 'hierarchy.lvl4', 'hierarchy.lvl5', 'hierarchy.lvl6', 'content', 'type', 'url'],

When using normal Algolia API details this still happens on the new theme.

Example response from Netlify Algolia response
image

Verses the VitePress DocSearch response
image

@kiaking
Copy link
Member

kiaking commented May 29, 2022

Oh, OK... I'm not that deep into Algolia but is this because of the algolia version is different in VitePress and Netlify? Or is Netlify DocSearch Plugin something totally different that we should be adding new config for it? 👀

@veryard
Copy link
Contributor

veryard commented May 31, 2022

Sorry for the delayed response, I think it may be beneficial for none open source users to be able to leverage their exisiting Algolia Crawler. It just comes down to how the crawlers attributes are setup. I will probably have a play when I have some time to allow the user to specify in the config which attributes the search works with.

@kiaking
Copy link
Member

kiaking commented Jun 16, 2022

Closing due to inactivity. I'm not still 100% sure what we should do with the issue. Please feel free to open a new issue if there's anything.

@kiaking kiaking closed this as not planned Won't fix, can't repro, duplicate, stale Jun 16, 2022
@kiaking kiaking added need more info Further information is requested and removed need more info Further information is requested labels Jun 16, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
brc-dd pushed a commit that referenced this issue Sep 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need more info Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants