@tryghost/algolia-indexer
v0.3.4
Published
Maintainers
Keywords
Readme
Algolia Indexer
@tryghost/algolia-indexer configures an Algolia index and saves or removes the records produced by the Ghost Algolia tools.
Install
npm install @tryghost/algolia-indexeror
pnpm add @tryghost/algolia-indexerUsage
Create an indexer with an Algolia application ID, Admin API key, and index name:
const IndexFactory = require('@tryghost/algolia-indexer');
async function indexFragments(fragments) {
const index = new IndexFactory({
appId: process.env.ALGOLIA_APP_ID,
apiKey: process.env.ALGOLIA_API_KEY,
index: process.env.ALGOLIA_INDEX
});
await index.setSettingsForIndex();
await index.save(fragments);
}Call initIndex() before delete(slug) when removing every fragment associated with a post slug. setSettingsForIndex() initializes the index and applies the package's required settings unless custom indexSettings are supplied to the constructor.
Development
Install dependencies from the repository root with pnpm install. From the root, run this package's tests and lint checks with:
pnpm --filter @tryghost/algolia-indexer testRun the full monorepo suite with pnpm test.
Copyright & License
Copyright (c) 2013-2026 Ghost Foundation - Released under the MIT license. Ghost and the Ghost Logo are trademarks of Ghost Foundation Ltd. Please see our trademark policy for info on acceptable usage.
