Couldn't get DocSearch to work

Hello,

I did the scraping myself following the instruction in https://github.com/algolia/docsearch-scraper, after which I was able to see the generated indices in my algolia dashboard. The search inside the algolia dashboard works great. But I have trouble integrating search to my site: I used the search-only api key in the javascript snippet, but every time when I initiate a search, there is error in console saying: Invalid Application-ID or API key. Any idea how to fix that?

Hi @qzhou.pku, can you share the JavaScript code you’re using to configure the search. Sounds like it could be a problem with the way that the client is being initialized.

Thank you for your reply @dzello. My JavaScript code is as below:

    docsearch({
        apiKey: '2ee58f908e6d720c4f72a9645ce0e857', // the search-only api key in my algolia account
        indexName: 'sonarwhal',
        inputSelector: '#search-input'
    });

Sorry if the code you see is not formatted. Not quite sure how to format the code in the forum.

For code formatting, you can use the </> icon in the editor, which will indent it by 4 spaces. Your code is formatted though, it’s just a few spaces indented more than it needs to be :slight_smile:

Because you are running the crawler yourself into your app, you will need to pass an appId to the docsearch object as well.

docsearch({
   appId: '....' // the Algolia app id where the data lives
   ...
});

I have added this information to the README on the DocSearch repository, I can definitely see how it was easy to miss. Let me know if this solutions works for you.

Yes it works now. I wished I have asked earlier - I eventually fixed it last night after digging into the code of docsearch and saw the option of overriding application id. Spent a whole day trying to figure out why it didn’t work… Thank you for your detailed reply back, and yes I think the documentation definitely needs to be more clear about it, at least in the scraper repo.

Really sorry that you lost a whole night on that :frowning:

I’ve also updated the scraper documentation with this commit.

I know it’s not much but can we send you a shirt and some stickers to say thanks for using DocSearch? If so, just fill out this form.

That’s awesome @dzello! I would love to have shirt/stickers from DocSearch! Will definitely fill the form out :grinning: Thank you for helping me out!

1 Like