Search Services
Use an external search service.
A search service hosts the index instead of the built-in search, and adds features like analytics, synonyms or semantic search. Each service has a plugin, which uploads your pages when the site builds and shows the service's results in the search dialog.
A service plugin also takes the built-in search's options, like filter, buildIndex, tags and the dialog options. The build uploads the pages with writeApiKey.
Keep Write Keys Out of the Code
Read writeApiKey from a build environment variable, never from a string in the code. When the variable is empty, the build warns and skips the upload, so the site searches the index as it is.
Algolia
Install the plugin with the service's client:
npm i @vuesho/algolia algoliasearchTurn off the preset's search, and add algoliaPlugin() with your application's keys:
import { algoliaPlugin } from "@vuesho/algolia";
import { createSite, recommendedPreset } from "vuesho/config";
import { defineDocs } from "vuesho/content";
const docs = defineDocs();
export default createSite(docs.toSource()).plugins(
recommendedPreset({ search: false }),
algoliaPlugin({
appId: "YOUR_APP_ID",
// The search-only key, which the browser searches with.
apiKey: "YOUR_SEARCH_API_KEY",
indexName: "docs",
writeApiKey: process.env.ALGOLIA_WRITE_API_KEY,
}),
);Prop
Type
vuesho build uploads the pages to the index. With multiple languages, each language has its own index, named with its key, like docs_cn.
Orama Cloud
Install the plugin with the service's client:
npm i @vuesho/orama-cloud @orama/coreimport { oramaCloudPlugin } from "@vuesho/orama-cloud";
createSite(docs.toSource()).plugins(
recommendedPreset({ search: false }),
oramaCloudPlugin({
projectId: "YOUR_PROJECT_ID",
// The public key, which the browser searches with.
apiKey: "YOUR_PUBLIC_API_KEY",
datasource: "YOUR_DATASOURCE_ID",
writeApiKey: process.env.ORAMA_PRIVATE_API_KEY,
}),
);Prop
Type
vuesho build uploads the pages to the datasource and deploys it. With multiple languages, datasource takes an ID per language, like { en: "…", cn: "…" }.
An index that the Orama Cloud crawler fills needs a custom dialog, as Search shows.
Meilisearch
The plugin works with a self-hosted Meilisearch instance and with Meilisearch Cloud.
Install the plugin with the service's client:
npm i @vuesho/meilisearch meilisearchapiKey is sent to the browser, so it must be a search key, as the Meilisearch security guide explains:
import { meilisearchPlugin } from "@vuesho/meilisearch";
createSite(docs.toSource()).plugins(
recommendedPreset({ search: false }),
meilisearchPlugin({
host: "YOUR_INSTANCE_URL",
// The search key, which the browser searches with.
apiKey: "YOUR_SEARCH_API_KEY",
indexName: "docs",
writeApiKey: process.env.MEILISEARCH_ADMIN_KEY,
}),
);Prop
Type
vuesho build replaces the index's documents with your pages. With multiple languages, one index holds every language's pages, and the dialog searches only the current language.
Typesense
The plugin works with a self-hosted Typesense server and with Typesense Cloud.
Install the plugin with the service's client:
npm i @vuesho/typesense typesenseimport { typesensePlugin } from "@vuesho/typesense";
createSite(docs.toSource()).plugins(
recommendedPreset({ search: false }),
typesensePlugin({
nodes: [{ url: "YOUR_SERVER_URL" }],
// The search-only key, which the browser searches with.
apiKey: "YOUR_SEARCH_ONLY_API_KEY",
collectionName: "docs",
writeApiKey: process.env.TYPESENSE_ADMIN_API_KEY,
}),
);Prop
Type
collectionName is an alias, so a search never reads a half-uploaded index, and the synonyms and curations carry over to each build. With multiple languages, each language has its own alias, like docs_cn.
Mixedbread
Mixedbread finds pages by meaning, not only by their words. Your server searches the store with a key that never reaches the browser, so the site needs a server.
Install the plugin with the service's client:
npm i @vuesho/mixedbread @mixedbread/sdkThe server searches with the key in the MXBAI_API_KEY environment variable, or with apiKey:
import { mixedbreadPlugin } from "@vuesho/mixedbread";
createSite(docs.toSource()).plugins(
recommendedPreset({ search: false }),
mixedbreadPlugin({
storeIdentifier: "YOUR_STORE_ID",
writeApiKey: process.env.MXBAI_WRITE_API_KEY,
}),
);Prop
Type
With multiple languages, one store holds every language's pages, and a search returns only the current language's.
Custom Fields
Algolia, Orama Cloud and Typesense store the extra fields that buildIndex adds to a page's index, for ranking and filters in the service. Meilisearch and Mixedbread store only the built-in fields.
import { algoliaPlugin } from "@vuesho/algolia";
import { buildIndexDefault } from "vuesho/search";
algoliaPlugin({
appId: "YOUR_APP_ID",
apiKey: "YOUR_SEARCH_API_KEY",
indexName: "docs",
writeApiKey: process.env.ALGOLIA_WRITE_API_KEY,
async buildIndex(page) {
const index = await buildIndexDefault.call(this, page);
// A `version` field on each record of the page, like "v2" for `v2/install.md`.
return { ...index, version: page.path.split("/")[0] };
},
});