如何在 Heroku 上托管的 ruby on Rails 项目中实现弹性搜索?
我的计划是在单独的 Linux 服务器上作为 Web 服务运行弹性搜索。然后,我将直接从我的应用程序调用它,以使用字符串或其他非结构化数据进行搜索。我不明白的是,这是否会基本上取代我的某些对象的数据库,或者在创建对象时,我是否应该在弹性搜索中索引它的 ID、对象类型和标签,并同时将整个对象保存到我的数据库中?然后我可以调用 Web 服务来获取对象的 ID,然后根据该 ID 查询数据库以检索实际对象?
这是考虑使用弹性搜索的正确方法吗?
My plan is to run elastic search on a separate linux server as a web service. Then I will make calls to it directly from my app to search with strings or other unstructured data. What I don't understand is will this basically replace my database for certain objects or at the time that the object is created, should I index it's ID, object type and tags in elastic search as well as simultaneously save the entire object to my database? Then I can make a call to the web service to get the object's ID and then query my database based on that ID to retrieve the actual object?
Is this the right way to think about using elastic search?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过两种方式使用 ElasticSearch:将其用作主存储,或用作搜索引擎。 Tire rubygem 允许您做到这一点,请参阅 README。
使用 ElasticSearch,将其用作数据源更有意义,因为它可以索引和存储任意 JSON。您可能希望将数据保存到单独的存储中以进行备份和冗余。
You can use ElasticSearch in both ways: using it as a primary storage, or as a search engine. The Tire rubygem allows you to do that, see the README.
With ElasticSearch, it makes more sense to use it as a source for data, since it can index and store arbitrary JSON. You may want to save your data into separate storage for backup and redundancy.