Skip to content

Instantly share code, notes, and snippets.

@rayrutjes
Created August 19, 2016 12:13
Show Gist options
  • Save rayrutjes/eb49da31d3e1fa916a2e7334826cbad5 to your computer and use it in GitHub Desktop.
Save rayrutjes/eb49da31d3e1fa916a2e7334826cbad5 to your computer and use it in GitHub Desktop.
Quick script to test calls to Algolia indices.
#!/usr/bin/env node
var algoliasearch = require('algoliasearch');
const APP_ID = 'whatever';
const API_KEY = 'whatever';
const INDEX_NAME = "test";
var client = algoliasearch(APP_ID, API_KEY);
var index = client.initIndex(INDEX_NAME);
index.search(
// search text (`query`)
"test",
// search parameters
{
"attributesToRetrieve": ["name"]
},
// callback
function (error, content) {
if (error) {
console.error("ERROR: " + error);
} else {
console.log(JSON.stringify(content, null, "    "));
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment