简体   繁体   中英

elasticsearch with node.js when using elmongo plugin

i have to html codes, first is for data submition and second is for elasticsearch,this is respectively.. first html=

<div > 
            Name:<input type="text" ng-model="angularData.Name" name="Name">
            email:<input type="text" ng-model="angularData.Email" name="Email">
            Phone:<input type="text" ng-model="angularData.Phone" name="Phone">


                  <button  ng-click="sendAngularRequest(angularData)"> Send </button>
            Response: {{succ.name}} : {{succ.email}} :{{succ.phone}} :{{succ.rating}} 
</div>

second html=

   search(Name-Email-Phone):<input type="text"    ng-model="elasticSearchData.searchName" name="search">

   <button  ng-click="sendElasticSearchRequest(elasticSearchData)"> Send </button>

>

before my elasticsearch code my data submition is working well but when iuse elmongo plugin like this code AngSchema.plugin(elmongo);

then my data submition terminate itself by programme and after this my server closed automatically , AngSchema is my model schema and my elasticsearch controller cade is given below-

require('../models/angular_model.js');

exports.elasticSearch = function(req, res) {

mongoose.connection.close();

AngModel = mongoose.model('AngModel');


mongoose.connect("mongodb://localhost/Ang_demo_app");
AngModel.sync(function(err, numSynced) {
    // all cats are now searchable in elasticsearch
    console.log('number of cats synced:', numSynced);
});

// AngModel.search({ query: req.body.searchName }, function (err, results) {
//      console.log('search results', results);
// });
// AngModel.search({ query: req.body.searchName, fuzziness: 0.5 }, function (err, results) {
//     console.log('search fuzziness results',results);
// });

console.log("This is elasticSearch");
console.log(req.body.searchName);

};

after this code running the server tells that *

number of cats synced: undefined

* but its's work first time and when i use to this next day that does not working,

can anyone help me please.........

actually there is no any support for elmongo ....

we can use mongoosastic in place of elmongo,i did this.it's working fine. you can fallow these two links. it's amazing dependency for node.js which support elasticsearch we can use it as a best alternate of elmongo.

http://pythonhackers.com/p/mahnunchik/mongoosastic

https://www.compose.io/articles/mongoosastic-the-power-of-mongodb-and-elasticsearch-together/

first link is better...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM