Docusaurus DocSearch TroubleShooting
Background
My Docusaurus(version 3.1.0) blog deploy on GitHub Page, before I change my domain from
https://halcyon666.github.io/summary/
to https://halcyon666.top
, the DocSearch v2 works in my site. When I apply the
DocSearch again for my new domain, I just do the same as before doing, the search doesn't work.
The URL Ignorance
Firstly I checked the crawler admin https://crawler.algolia.com/, I found many website url be ignore, because there are many 302 redirection in my new application.
I try search in the Preview Search, There is not a result about my markdown blogs except homepage informations.
you can see my correct configuration above, and the wrong configuration below, in this case solve the scrawler ignore problems.
new Crawler({
sitemaps: [],
ignoreCanonicalTo: false,
});
In this time I can search in the Search Preview, but not in my site.
The Invalid Application-ID or API key
resolve Invalid Application-ID or API key, I check the helpful url, and find my API Key is wrong, given by the DocSearch rely email, so when you encounter this error, you need check your API key in your dashboard
The misunderstand faceFilters
Has result in Preview Search , but not in my site.
I get both payload from Preview Search and my site, I compare those parameters, and find that there some different with my parameters.So I checked the docusaurus docs, and fix this by changing the configuration.
This is the wrong payload Parameter in the end of the request url.
facetFilters=["language:zh",["docusaurus_tag:default","docusaurus_tag:docs-default-current"]]
and my wrong configuration is
contextualSearch: true,
searchParameters: {},
You need to indicate the contextualSearch to false(hint: this configuration in docusaurus.config.ts
or docusaurus.config.js
), and write you language filter to in brackets. You can see my fixed example below.
contextualSearch: false,
searchParameters: {
// maybe yours is en
facetFilters: ["zh"],
},