简体   繁体   English

Ruby on Rails-搜索适合我的宝石

[英]Ruby on Rails - Search gem that fits my needs

I am looking for a search gem and found searchkick really interesting. 我在寻找搜索宝,发现searchkick真的很有趣。

I've got a few questions before implementing it 在实施之前,我有几个问题

  • Looked up the internet and didn't find anything about multiple resource search. 查找了互联网,没有找到有关多资源搜索的任何信息。 Is it possible? 可能吗? For example: I have a model Post and User - can I search for them in just one search box? 例如:我有一个“帖子和用户”模型-我可以在一个搜索框中搜索它们吗?
  • would this be a good idea in first case? 在第一种情况下这是个好主意吗? would a search icon in the navbar make more sense? 导航栏中的搜索图标会更有意义吗? (click on it and get redirected to search page with multiple search boxes) (单击它并重定向到带有多个搜索框的搜索页面)

thanks 谢谢

you can use elasticsearch . 您可以使用elasticsearch you can work with only one search box for all of it. 您只能使用一个搜索框进行搜索。 it's a little complicated but it does support relations too 这有点复杂,但它确实也支持关系

You can use multi-search in Searchkick for this purpose. 为此,您可以在Searchkick中使用多重搜索。 https://github.com/ankane/searchkick#multi-search https://github.com/ankane/searchkick#multi-search

Thats exactly what you're looking for: https://github.com/activerecord-hackery/ransack 那正是您正在寻找的东西: https : //github.com/activerecord-hackery/ransack

In your Gemfile, for the last officially released gem: 在您的Gemfile中,查看最后一个正式发布的gem:

gem 'ransack'

If you would like to use the latest updates (recommended), use the master branch: 如果要使用最新更新(推荐),请使用master分支:

gem 'ransack', github: 'activerecord-hackery/ransack'

And here's an article about how to use it basicly: https://medium.com/@jaspercurry/searching-and-sorting-on-rails-with-ransack-560e862e650a 这是有关如何基本使用它的文章: https : //medium.com/@jaspercurry/searching-and-sorting-on-rails-with-ransack-560e862e650a

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM