Hybrid Couchdb/Elasticsearch engine for Resourceful
Start up an empty instance of CouchDB and an empty instance of Elasticsearch, then do this:
var resourceful =Couchelastic = Couchelastic;resourcefulenginesCouchelastic = Couchelastic; // patch in the engineresourceful;
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 options you might want to use. Everything specified within the options.search is passed straight into ES's Mapping API, allowing you fine-grained control over how that individual field is treated in the index.
var Creature = resourceful;
sync() method sets up your data sources for you. Until you sync you can
get() but not much more.
sync does the following:
You'll need to
sync after you make any significant design changes so that they're carried through to the schemas of both servers. Be aware that changing the data type of a field after data has already been indexed can be problematic.
Assuming you've defined a Creature as per the Resourceful docs you should be able to search your database in free text like this.
You can also search using the Elasticsearch query DSL, for example the following
fuzzy query would also match the word "oscar"
Or using Resoureceful's parametric query method
If you have two data types related by a one-to-many foreign key you can do this (many-many not available yet):
If some of your Resource data is sensitive you might want to block it from being indexed
var Employee = resourceful;
TODO - clean up the object search API and allow faceting etc.
npm install resourceful-couchelastic`
$ npm test