I tried to search online for a solution but to be honest I still didn't found anything that help me to achieve this.
It is the first time I use ElasticSearch and I'm also pretty new with Node and MongoDB.
So, I followed a kind of tutorial and implemented Mongooastic from NPM to let ElasticSearch work with Node.
It seems to work fine even if on a total of 12 users indexed, if I type in the search "user" in the search list view I can find 12 records, it show 10 in a for each and the first one has missing values...
But the main problem for me is the pagination... or a sort of... it will be also nice to implement infinite scroll on it but I don't really know how to handle it.
So, the controller that handle it is the following at the moment:
exports.searchUsers = function(req, res) {
User.search({
query_string: {
query: req.query.q
}
},
{ hydrate: true },
function(err, results) {
if (err) res.send(err);
res.render('search-results', {
results: results,
users: results.hits.hits
});
});
};
I don't really know where to put size and from in here... and after understanding this I also would like to know how to implement, if possible, a sort of infinite scroll... And also how to handle link for the pagination... i.e.: prev, 1, 2, 3, 4, ..., next
The view has a simple input text for the search, after pressing submit it open a new page with the list of hits, so it should be nothing complex...
I hope you may help. Thanks