Skip to main content

Algolia

Algolia is the leader in globally scalable, secure, digital search and discovery experiences that are ultrafast and reliable.

Official Websitehttps://algolia.com/
Tagsalgolia

Credential configuration

Before you can index your data or search your Algolia indices, you must initialize the client with your application ID and API key. You can find both in your Algolia account.

Extended options support any additional parameter like headers, host or timeouts.

Here is an example of a filled credential configuration form in YepCode:

Algolia Snippets available in editor

note

The title is the triggering text for YepCode to autocomplete the script.

Integration

New integration from credential
const algolia = yepcode.integration.algolia('credential-slug')
New integration from plain authentication data
const algoliasearch = require('algoliasearch');
const algolia = algoliasearch('your-application-id', 'your-write-api-key');

Search Index

Search index
const index = algolia.initIndex('your-index-name');
index.search('your query string').then(({ hits }) => {
console.log(hits);
});

Save Objects

Save objects
const index = algolia.initIndex('your-index-name');

const objects = [{
firstname: 'Jimmie',
lastname: 'Barninger',
objectID: 'myID1'
}, {
firstname: 'Warren',
lastname: 'Speach',
objectID: 'myID2'
}];

index.saveObjects(objects).then(({ objectIDs }) => {
console.log(objectIDs);
});

Save Single Object

Save single object
const index = algolia.initIndex('your-index-name');

index.saveObject({
firstname: 'Jimmie',
lastname: 'Barninger',
objectID: 'myID1'
}).then(({ objectID }) => {
console.log(objectID);
});

Delete Objects

Delete objects
const index = algolia.initIndex('your-index-name');
index.deleteObjects(['myID1', 'myID2']).then(({ objectIDs }) => {
console.log(objectIDs);
});