Skip to content

Introduce dreyfus into couchdb

Robert Newson edited this page Jun 1, 2017 · 3 revisions

Introduce dreyfus into couchdb

1. download couchdb

git clone https://github.com/cloudant/couchdb.git  

2. switch to branch

cd couchdb  

3. modify rebar.config.script

DepDescs = [
...
{dreyfus,          "dreyfus",          "master"},
...
MakeDep = fun	
    ...
    ({AppName, RepoName, Version}) when AppName == dreyfus ->
        Url = "https://github.com/cloudant-labs/" ++ RepoName ++ ".git",
        {AppName, ".*", {git, Url, Version}};
    ...
end,

configure CouchDB and its dependencies

./configure --disable-fauxton --disable-docs

add dreyfus to application list to be started

a. add dreyfus_epi plugin to couch_epi.config under rel/apps/ directory

{plugins, [
    couch_db_epi,
    chttpd_epi,
    couch_index_epi,
    dreyfus_epi,
    global_changes_epi,
    mango_epi,
    mem3_epi,
    setup_epi
]}.

b. add dreyfus to reltool.config under rel directory

{sys, [

    {rel, "couchdb", "2.0.0a", [
        ...
        couch_peruser,
        ddoc_cache,
        dreyfus,
        ets_lru,
        ...
    ]},
    %% couchdb

    {app, couch_peruser, [{incl_cond, include}]},
    {app, ddoc_cache, [{incl_cond, include}]},
    {app, dreyfus, [{incl_cond, include}]},
    {app, ets_lru, [{incl_cond, include}]},
 ]}

c. download dreyfus.js to share/server/dreyfus.js

curl https://raw.githubusercontent.com/cloudant/couchdb/c323f194328822385aa1bb2ab15b927cc604c4b7/share/server/dreyfus.js > share/server/dreyfus.js

d. modify file support/build_js.escript

main([]) ->
    JsFiles = [...
               "share/server/dreyfus.js",
               "share/server/loop.js"],

    CoffeeFiles = [...
                   "share/server/dreyfus.js",
                   "share/server/coffee-script.js",
                   "share/server/loop.js"],

e. add the exposed functions to share/server/loop.js to be able to call them in a view

function init_sandbox() {
  try {
      ...
      sandbox.index = Dreyfus.index;
  } catch (e) {
    //log(e.toSource());
  }
};

var Loop = function() {
  var line, cmd, cmdkey, dispatch = {
    ...
    "index_doc": Dreyfus.indexDoc
  };

f. talking To Clouseau add lines in rel/overlay/etc/local.ini and rel/overlay/etc/default.ini

[dreyfus]
name = {{clouseau_name}}

g. modify file dev/run

	"cluster_port": cluster_port,
	"backend_port": backend_port,
	"fauxton_root": fauxton_root,
	"clouseau_name": "clouseau%[email protected]" % (idx+1),
	"uuid": "fake_uuid_for_dev"

Build couchdb

make

Start Couchdb

dev/run --admin=foo:bar

Download and Start Clouseau

git clone https://github.com/cloudant-labs/clouseau
cd clouseau
mvn scala:run -Dlauncher=clouseau1

Search

Feel free to follow our tuturials for search: https://cloudant.com/for-developers/search/ and https://cloudant.com/blog/search-faceting-from-scratch–2. There is also video tutorial available at https://www.youtube.com/watch?v=IdiCmKINL9g.

Reference

Introduce GeoSpatial Index To CouchDB https://github.com/cloudant/hastings/wiki/Introduce-GeoSpatial-Index-To-CouchDB

Adding dreyfus to couchdb https://gist.github.com/rnewson/bdb8e84dcd56beb533b1

Enable Full Text Search in Apache CouchDB https://cloudant.com/blog/enable-full-text-search-in-apache-couchdb/#.WB9FOZNS1-U

Search https://cloudant.com/for-developers/search/

Build and query a search index https://cloudant.com/blog/search-faceting-from-scratch–2