Algolia for node.js and Mongodb

孤者浪人 提交于 2020-01-13 16:09:16

问题


I have a problem right now, Algolia does provide a rich documentation regarding node.js but my problem right now are

1) how do i import mongodb database to algolia server? seems like they are showing how to use MySql database instead of Mongodb with node.js

2) Im using ejs to render the html, so do i need to query the value of a search using node.js or just let the clientside html handle it?

because with ejs I have to use

app.get("/testingSearch", function(req, res) {

  res.render('testing', { message: value});
})

app.post("/postSearch", function(req, res) {
  // some searching 
  var name = req.body.name;
  // algolia
});

Anyone who has an experience with algolia + node.js + mongodb , please lend me your advise. Thank you


回答1:


MongoDB

If you just want to have a complete replica of a collection, you can use the Algolia's MongoDB connector.

However, if you want to do a more advanced indexing, you should add algolia indexing calls alongside the calls to your database.

Rendering

Algolia has been designed to be used in your front-end. See this FAQ entry. However, for SEO purposes, a back-end search might make sense to you. Since the JS client is isomorphic, you can mix the two pretty easily.



来源:https://stackoverflow.com/questions/33169228/algolia-for-node-js-and-mongodb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!