Wednesday, 15 August 2012

angularjs - How to integrate Elastic Search with Meanjs (Mongodb ,Express,Angular,Nodejs) -



angularjs - How to integrate Elastic Search with Meanjs (Mongodb ,Express,Angular,Nodejs) -

i have installed meanjs grunt . existing modules working properly. issue trying integrate elastic search angular js . didn't proper solution. when connecting elastic search server.js .then on terminal shows search result. how diplay search result through angular js on home page.

i want connect elastic database mongodb database elastic search auto update. suggestion helpful me. connecting through elastic search using

var myopenrecipes = angular.module('myopenrecipes', ['elasticsearch'], ['$locationprovider', function($locationprovider){ $locationprovider.html5mode(true); }] ); myopenrecipes.factory('recipeservice', ['$q', 'esfactory', '$location', function($q, elasticsearch, $location){ var client = elasticsearch({ host: $location.host() + ":9200" }); /** * given term , offset, load round of 10 recipes. * * returns promise. */ var search = function(term, offset){ var deferred = $q.defer(); var query = { "match": { "_all": term } }; client.search({ "index": 'facilities', "type": 'facility', "body": { "size": 10, "from": (offset || 0) * 10, "query": query } }).then(function(result) { var ii = 0, hits_in, hits_out = []; hits_in = (result.hits || {}).hits || []; for(;ii < hits_in.length; ii++){ hits_out.push(hits_in[ii]._source); } deferred.resolve(hits_out); }, deferred.reject); homecoming deferred.promise; }; homecoming { "search": search }; }] );

essentially want this:

run elastic search (es) server. on server-side code (mean), you'll write route handles searching. make angular code send requests backend route searching via es.

you don't want have angular straight speak es on network -- afaik there's no way safely this.

angularjs node.js mongodb elasticsearch meanjs

No comments:

Post a Comment