Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8703417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:51:44+00:00 2026-06-13T02:51:44+00:00

I have a simple rails 3 application that lists restaurants as a training exercise.

  • 0

I have a simple rails 3 application that lists restaurants as a training exercise. I want to be able to search name and description using one textfield on the restaurant index page.

Given the query pizza. The matches should be

  • name: Tony’s, description: … is a pizzeria that has been around since the 1950’s …
  • name: Domino’s Pizza, description: …
  • name: The Hall, description: … pizzas, pastas and steaks …

Because:

  1. the word pizza is a fuzzy match to ” pizz eri a ” using similar logic as TextMate’s Cmd-T. (the spaces in the word pizzeria are only used to get the mini-Markdown to work)
  2. pizza is a lowercase match to Pizza
  3. pizza is a substring of pizzas (should work with ends-with begins-with and includes)

How would I go about doing this in rails 3? Do I use thinking_sphinx, tire, sunspot-rails or just a custom query for my application.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:51:45+00:00Added an answer on June 13, 2026 at 2:51 am

    I found a very simple solution that serves my needs.

    "%#{"pizza".scan(/./).join("%")}%"
    

    This creates a string that looks like this

    "%p%i%z%z%a%"
    

    Then I use it in a LIKE query and I get the expected results. Now all that remains is to solve the non-trivial problem of determining the order of relevance 🙂

    UPDATE:

    Found a quick and dirty way of determining order of relevance base on the assumption that a shorter string will most likely be a closer match than a longer one.

    ORDER BY length(sequence) ASC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Rails application that I want to be able to jump to
I have built a very simple blog application using Ruby on Rails. New to
I have made a simple Rails application that allows people to comment on posts.
I have a really simple Rails application that allows users to register their attendance
I have a simple Rails 3 example application that I'm trying to work out
I have a simple Rails application I'm using to try and learn Rails. It
I have created a rails application that has a simple RESTful json API. This
i have a very simple rails application that is ajax-based for some of it's
I have a fairly simple Rails application that allows users to manage their clients
I have a Rails simple application that has two main models. A person model

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.