简体   繁体   English

谁能推荐一个搜索用的宝石,它实际上可以让我轻松地将结果过滤在红宝石上?

[英]Can anyone recommend a gem for searching that actually allows me to easily filter my results in ruby on rails?

I've tried thinking sphinx after being pointed in that direction and simple filtering seems impossible. 在尝试指向狮身人面像之后,我尝试过使用狮身人面像,而简单的过滤似乎是不可能的。 I've googled and asked questions for 2 days now and it seems it can't be done which is shocking because it's something commonly done when searching on websites. 我已经搜寻并询问了2天的问题,似乎无法完成,这令人震惊,因为这是在网站上搜索时通常会做的事情。

All I would like to do add filtering options to my search form such as filtering by one or a combination of: 我要做的就是在搜索表单中添加过滤选项,例如按以下一项或组合进行过滤:

When user hits browse page all the sites users are returned but showing 20 results per page 当用户点击浏览页面时,将返回所有站点用户,但每页显示20条结果

Filtering options 筛选选项

in: location 在:位置

who are: sexual preference 谁是:性偏好

between the ages: age range 年龄之间:年龄段

and located in: country 并位于:国家

My search page works fine because all I require is 1 textfield a user uses for finding users by email, username or full name. 我的搜索页面工作正常,因为我需要的只是一个用户用于通过电子邮件,用户名或全名查找用户的1个文本字段。 My browse page is a different story because I'm using 1 form with multiple text fields and one or two select fields. 我的浏览页面是另一回事,因为我使用的是一种表单,其中包含多个文本字段和一个或两个选择字段。

Example

Is there a gem that does this easily and performs well at the same time? 有没有一颗宝石可以轻松做到这一点并同时表现出色?

or would doing this manually via find methods be the only way? 还是通过find方法手动执行此操作是唯一方法?

Kind regards 亲切的问候

You can go for Elasticsearch. 您可以去Elasticsearch。 Ruby has the 'Tire' gem, which is a client for ElasticSearch http://www.elasticsearch.org/ Ruby拥有“轮胎”宝石,它是ElasticSearch http://www.elasticsearch.org/的客户端

Apart from using Sphinx and Thinking Sphinx, you can think of those gems: meta_where and meta_search 除了使用Sphinx和Thinking Sphinx外,您还可以想到那些瑰宝: meta_wheremeta_search

However after reading your description I think Sphinx is the best choice here indeed. 但是,阅读完您的描述后,我认为Sphinx确实是最佳选择。

You wrote that it seems impossible to apply simple filtering using Thinking Sphinx. 您写道,使用Think Sphinx应用简单过滤似乎是不可能的。 Let me explain a bit of Thinking Sphinx within the post you mentioned under the link: Example 让我在您在链接下提到的帖子中解释一下Think Sphinx: 示例

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

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