我现在有一个问题,Algolia 确实提供了关于 node.js 的丰富文档,但我现在的问题是
1) 如何将 mongodb 数据库导入 algolia 服务器?似乎他们正在展示如何在 node.js 中使用 MySql 数据库而不是 Mongodb
2) 我使用 ejs 来呈现 html,所以我需要使用 node.js 查询搜索的值还是让客户端 html 处理它?
因为使用 ejs 我必须使用
app.get("/testingSearch", function(req, res) {res.render('testing', { message: value});})app.post("/postSearch", function(req, res) {//一些搜索var name = req.body.name;//算法});任何对 algolia + node.js + mongodb 有经验的人,请给我您的建议.谢谢
解决方案MongoDB
如果您只想拥有一个集合的完整副本,您可以使用 Algolia 的 MongoDB 连接器.
但是,如果您想要进行更高级的索引,您应该在对数据库的调用旁边添加 algolia 索引调用.
渲染Algolia 旨在用于您的前端.请参阅此常见问题解答.但是,出于 SEO 的目的,后端搜索可能对您有意义.由于 JS 客户端是同构的,因此您可以很容易地将两者混合.
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
解决方案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.
RenderingAlgolia 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.
更多推荐
用于 node.js 和 Mongodb 的 Algolia
发布评论