gpt4 book ai didi

javascript - 使用 Solr 或 ElasticSearch 作为 API 最佳实践

转载 作者:行者123 更新时间:2023-11-30 10:38:03 25 4
gpt4 key购买 nike

我正在考虑将 Solr 或 ElasticSearch 用于一些客户端 javascript 应用程序。在一个实例中,我可以直接调用 API。

我对这个概念很陌生,首先想到的事情之一是如何避免安全相关问题,例如人们针对 API 发出删除命令?将搜索 API 隐藏在一个层之后是否合适,例如与客户端交互的小型 PHP 或 Sinatra API?

谢谢!

最佳答案

Is it appropriate to hide the search API behind a layer, like a small PHP or Sinatra API to that client interacts with?

如果您关心安全,答案无疑是 -
NodeJS 非常适合这类事情:授权客户端请求,将查询发送到 elasticsearch/solr,然后将其发送回客户端(在返回途中进行或不进行数据处理)。如果您有很多连接(nodejs 非常适合),PHP 不太适合。


参见 this article 的第二部分在 elasticsearch 的博客上。有一个很好的代理插图,还有一个简单的 Ruby code for the proxy .

那里的相关引述:

This all is possible by leveraging the fact that elasticsearch exposes an HTTP API. By putting a proxy in front of it, we can isolate the authentication and authorization routines into separate components, effectively de-composing the responsibilities in the stack and allowing for better testability of individual parts.

关于javascript - 使用 Solr 或 ElasticSearch 作为 API 最佳实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12848033/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com