Hybrid Couchdb/Elasticsearch engine for Resourceful
Start up an empty instance of CouchDB and an empty instance of Elasticsearch, then do this:
var resourceful = require'resourceful'Couchelastic = require'resourceful-couchelastic'Couchelastic;resourcefuluse'couchelastic'database:'couchelastic-sync-test';
From this point onwards each
Resource that you define will have its data stored in your specified
CouchDB cluster and have an Elasticsearch indexing river configured to index the data for searching.
Assuming you're already defining resources with Resourceful nothing more is required, but there are some additional optional you might want to use.
If some of your Resource data is sensitive you might want to block it from being indexed
var Employee = resourcefuldefine'Employee'thisstring'name';thisnumber'salary'searchable:false;;
TODO - maybe just pass through mapping options transparently for flexibility
Assuming you've defined a Creature as per the Resourceful docs you should be able to search your database in free text like this.
Creaturesearch"fur"// creatures is an array of Creature objects that match the search;
You can also search using the Elasticsearch query DSL
Creaturesearchterm:legs:4eats:"wasps"// creatures is an array of Creature objects that match the search;
TODO - clean up the object search API and allow faceting etc.
npm install resourceful-couchelastic`
$ npm test