Advice with Full Text Search Engine in Rails - ruby-on-rails

I am trying to add to my website a search bar like the one on Facebook. I want my users to be able to search through my products, my other users ... But I also want the result to be displayed in real time without pressing a button. I am currently looking at several options (thinking-sphinx, ferret, ...) but I am not sure which one to use and that's why I would like to get advices from pros ;)
So my requirement are :
Result to be displayed in real-time in a box on the current page.
Css Customizable
Be able to search through severals table in my PostGreSQL DB.
I am currently using Heroku for production.
I want to choose the best one for my needs and that's why I am asking your opinion.
Thanks in advance !

Make sure to separate how you want data displayed (your first two requirements) from how you want it indexed (third) from how you want to deploy.
Let's start backwards. Heroku provides limited support for machine configuration; both options you mention require installation of a service that reads and writes files. Heroku has such an option in two ways: 1) PostgreSQL has a built-in full-text search capability, and 2) Heroku has made Flying Sphinx an option, as well as these other options documented on the Heroku site. The first two options may provide the easiest linkage to your database, but I haven't tried other options, so it's possible they do too. So now you have a search index, deployed.
Real-time "incremental" search is purely a matter of presentation ... and maybe performance. Start typing and you start getting results is nothing more than sending requests via AJAX to the search server, typically after a short delay in typing (maybe 50ms), and handling the display of results. There are a couple of ways to make that simple written up here in this SO answer.

I ended up keeping the PostgreSQL engine for now but used select2 as the jquery for the presentation and was able to get a facebook like search box :
Select2 with Rails and JSON
Thanks for you help !

Related

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.
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
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
You can go for Elasticsearch. Ruby has the 'Tire' gem, which is a client for ElasticSearch http://www.elasticsearch.org/

Rails request statistics gem?

I'm looking for a rails plugin to show request statistics (# of sql queries, time, etc) on each request while in development mode. Something like http://getglimpse.com/ would be great. I've seen one or two of these before but for the life of me I can't find them. Any help?
Ideally, it would show in the header or the footer of every page.
I found a few including the one I was thinking about and some others.
This one is amazing so far:
https://github.com/dsboulder/query_reviewer
This is the one I was thinking of:
https://github.com/josevalim/rails-footnotes
This seems to be a similar but better plugin to rails-footnotes:
https://github.com/brynary/rack-bug
May be best to mix and match these, try rack-bug and query_reviewer
A few others are linked from query_reviewer

UI Dialog to search and add clients to a list

I need to implement a dialog for a web application (ASP.NET/C#) where users can search and select one or more clients from the company's database.
Actually an existing version is already used (see attached image) and I have to replace it with a new version (it comes from an external legacy software and will be dismissed).
The goal is to provide an intuitive and easy to use GUI, still providing the basic functionalities like: search for a client and add it or remove previously inserted.
My idea would be to develop the dialog with jQuery Dialog plugin and using web methods and Ajax/JSON to interact with them for interacting with the server and the DB. I cannot find a good solution yet for the contacts list, since I would avoid using GridViews or tables, if possible, for listing them.
Does anyone knows if further plugins or best patters exist for develop this UI and its functionalities?
I wanted to have the same in my application. After talking to the users i found that such dialog could easily be replaced by an Autocomplete with Multiple select.
See the jqueryUI demopage here.
If this does not fit your needs i would go with two lists <ol> or <ul>, a pagination plugin and perhaps a search plugin. But haven't done this so far.
Thanks for the hint, indeed for the search I also thought to a autocomplete for make the search easier.
My bigger concerns were about the Add and Remove selected Clients in a "modern" fashion.
I found this MultiSelect plugin that works perfectly for my needs (and maybe it could be useful for yours as well).
Not only it let use Multiselect to add/remove entries, but also have some auto-filtering capabilities when searching the entries. I will try to add this to my solution.

Search Engine Help

I have a mediawiki installation that I've customized with some of my own extensions. Here is the basic platform, pretty standard LAMP install.
Ubuntu Server
Apache 2
Mediawiki 1.15
PHP 5.2.6
MySQL 5.0.67
For the actual MW search I use Lucene (EzMwLucene). I also have custom extension that displays tabular data from a separate database within a MW page. Lucene doesn't index this info (which, in my case is actually good because it would clutter your expected search results). For this installation I didn't do anything to Lucene other than install it and wouldn't know how to customize it for my needs and it may be "too powerful".
At any rate, I need to create a search for the data in my other database. I have a master table that is updated daily based on data stored in other (normalized) tables. At the moment it is one of these searches that basically creates a SQL query based on the criteria you enter. This is a lot of work, though. I would like it to be more of a "type and submit" type search.
I don't think I need a comprehensive "cut & paste" type answer, but if anybody has something that I can google I would be very appreciative. I don't need to recreate the wheel, which is what I would be doing if I followed what I see in google.
If you would like to see my master database, let me know, I would want to sanitize it to make me more anonymous (whatever that means). Also, if you're familiar with MW and would like to see any of my extension code, again, let me know.
TL;DR: need to make a custom search feature with LAMP (displayed in Mediawiki). Any guidance appreciated.
Thanks SO!
Why do you need to add custom search? This will relate to the best answer.
For simplicity, you could use the Google Search Engine - http://www.mediawiki.org/wiki/Extension:Google_Custom_Search_Engine
Otherwise it sounds like you need to write a full-text query for the database.

How do I add a twitter search feed to my Ruby on Rails application?

I want to add a twitter feed for a specific keyword search to my rails application. Where should I start?
You might start with one of the Twitter API libraries written for Ruby.
You may want to consider grabbing the RSS feed for the search and parsing that. I show that in Railscasts episode 168. If you need something more fancy the API is the way to go as Dav mentioned.
But whichever solution you choose, it's important to cache the search results locally on your end. This way your site isn't hitting Twitter every time someone goes to the page. This improves performance and will make your site more stable (not breaking when twitter breaks). You can have the cache auto-update every 10 minutes (or whatever fits) using a cron task.
We download and store the tweets in a local database. I recently wrote a blog post about how I achieved this:
http://www.arctickiwi.com/blog/16-download-you-twitter-feed-using-ruby-on-rails-with-oauth
You can then use will_paginate to handle your pagination and go back as far as you want.

Resources