Multiple Algolia search index? #8467
Replies: 1 comment 5 replies
-
|
Hi We assign metadata tags to each page for the search crawler. For example your regular docs: https://docs.typebot.io/ Your API ref docs: https://docs.typebot.io/api <meta name="docusaurus_tag" content="default" data-rh="true">The plugin you use for the API docs does not populate Now we have the concept of "contextual facet filters" which permit to craft an Algolia query based on the current path. // Translate search-engine agnostic search filters to Algolia search filters
export function useAlgoliaContextualFacetFilters(): [string, string[]] {
const {locale, tags} = useContextualSearchFilters();
// Seems safe to convert locale->language, see AlgoliaSearchMetadata comment
const languageFilter = `language:${locale}`;
const tagsFilter = tags.map((tag) => `docusaurus_tag:${tag}`);
// [] = AND query
return [languageFilter, tagsFilter];
}Unfortunately I don't think you can swizzle that file anymore but you can probably create a Webpack alias to override it with your own implementation, and use the // Translate search-engine agnostic search filters to Algolia search filters
export function useAlgoliaContextualFacetFilters(): [string, string[]] {
const {pathname} = useLocation()
const {locale, tags} = useContextualSearchFilters();
if (pathname.startsWith("/api/") {
return ["docusaurus_tag:my-api-ref-tag"]
}
// Seems safe to convert locale->language, see AlgoliaSearchMetadata comment
const languageFilter = `language:${locale}`;
const tagsFilter = tags.map((tag) => `docusaurus_tag:${tag}`);
// [] = AND query
return [languageFilter, tagsFilter];
}Not sure we provide any better way to do that currently. Maybe @shortcuts has another idea? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a doc with a sub path
/apithat points to the API doc.I'd like to change the Algolia search index based on this:
If user in documentation (every page other than
/api/**) then don't show search results from Typebot API indexOtherwise, use the API index
How can I achieve this?
Beta Was this translation helpful? Give feedback.
All reactions