Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Cloudant Index Creation using node and nano.js
nano doesn't yet have support for Cloudant's new index feature,
but you can still do it using nano's request function.
This code creates an index.
To try this, first replicate the database as per
instructions here:
Then install nano like so:
npn install nano
And then run this file (after replacing USERNAME
and PASSWORD with your own):
node create_C_index.js
Then here's some sample code for querying:
var nano = require('nano')({ url: 'https://[USERNAME]:[PASSWORD]@[USERNAME]' });
var query = {
"index": {
"fields": ["Person_name"]
var opts = {
path: '_index',
db: 'movies-demo',
method: 'post',
body: query
nano.request(opts, function(err, result) {
// err should be null
// result should be { result: 'created' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment