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

偶尔善良 提交于 2019-12-25 06:46:49

问题


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.

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

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. 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?

Kind regards


回答1:


Apart from using Sphinx and Thinking Sphinx, you can think of those gems: meta_where and meta_search

However after reading your description I think Sphinx is the best choice here indeed.

You wrote that it seems impossible to apply simple filtering using Thinking Sphinx. Let me explain a bit of Thinking Sphinx within the post you mentioned under the link: Example




回答2:


You can go for Elasticsearch. Ruby has the 'Tire' gem, which is a client for ElasticSearch http://www.elasticsearch.org/



来源:https://stackoverflow.com/questions/9044610/can-anyone-recommend-a-gem-for-searching-that-actually-allows-me-to-easily-filte

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!