Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Searching for local couchdb via elasticsearch #31

Open
sysadminmike opened this issue Jun 28, 2014 · 0 comments
Open

Searching for local couchdb via elasticsearch #31

sysadminmike opened this issue Jun 28, 2014 · 0 comments

Comments

@sysadminmike
Copy link

I have made a small change to the article.js to allow for searching for normal couchdb setups via elasticsearch and the couchdb river
https://github.com/elasticsearch/elasticsearch-river-couchdb

Once the river plugin is installed setup the river for articles:

curl -XPUT 'http://elasticsearch_host:9200/_river/articles/_meta' -d '{
"type" : "couchdb",
"couchdb" : {
"host" : "couchdb_host",
"port" : 5984,
"db" : "articles"
}


Install elasticsearch node client

npm install --save elasticsearch


Changes to: includes/article.js

var articles = require('./cloudant.js').articles;

var moment = require('moment');
var async = require('async');
var mc = require('./mc.js');
var elasticsearch = require('elasticsearch');

Replace the search part from line 322

var search = function (keywords, callback) {
var client = new elasticsearch.Client( { host: 'elasticsearch_host:9200', log: 'info' } );
client.search({
q: keywords, index: "articles", size: 99
}).then(function (body) {
retval = [];
for (i = 0; i < body.hits.hits.length; i++) {
retval.push(body.hits.hits[i]._source);
}
callback(false, retval);
}, function (error) {
console.trace(error.message);
});
};

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant