用于 node.js 和 Mongodb 的 Algolia

编程入门 行业动态 更新时间:2024-10-24 16:23:21
本文介绍了用于 node.js 和 Mongodb 的 Algolia的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我现在有一个问题,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.

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.

更多推荐

用于 node.js 和 Mongodb 的 Algolia

本文发布于:2023-11-28 19:42:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643706.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:js   node   Algolia   Mongodb

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!