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 7839651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:30:20+00:00 2026-06-02T15:30:20+00:00

Ruby on Rails -> ThinkingSphinx -> SphinxSearch -> Mysql I want to search the

  • 0

Ruby on Rails -> ThinkingSphinx -> SphinxSearch -> Mysql

I want to search the titles table. The expected user keyword will not be an exact match, it will be a partial match.

search_key = "android samsung galaxy ace black phones"

Searching against the titles table,

titles(table)

id | titles

1 | nokia c6
2 | samsung galaxy ace
3 | samsung galaxy ace y
4 | nokia lumia 800
5 | samsung monte
6 | samsung galaxy note

case – 1 :

Title.search search_key, :match_mode => :all

=>No results

Comment: Bad

case -2 :

Title.search search_key, :match_mode => :any

=>[samsung galaxy ace, samsung galaxy ace y, samsung monte, samsung galaxy note]

Comment: OK, but not relevant, the user wanted only “samsung galaxy ace” which she specified in her keywords explicitly. Why show other samsung mobiles ?

case -3 :

Title.search 'search_key/3',:match_mode => :extended

=> samsung galaxy ace

Comment: Bingo!, but hard coded.

Question:

Now, I should know how many number of keywords will get an exact match in the titles table. (For example, its 3 for “samsung galaxy ace” in “android samsung galaxy ace black phones”)

How do I go around this?. Sphinx handles this?. If not what to do ?

  • 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-02T15:30:21+00:00Added an answer on June 2, 2026 at 3:30 pm

    One way is to store a wordcount in the sphinx index as attribute.

    sql_field_str2wordcount is a good way to do this
    http://sphinxsearch.com/docs/current.html#conf-sql-field-str2wordcount

    You can then use it as a basis of a filter

    $cl->setMatchMode(SPH_MATCH_EXTENDED);
    $cl->setRankingMode(SPH_RANK_WORDCOUNT);
    $cl->setSelect("*,IF(@weight=>titles,1,0) as myfilter");
    $cl->setFilter("myfilter",array(1));
    $cl->Query("\"$search_key\"/1",'Title');
    

    (Sorry, dont know how to do this in thinking-sphinx particully. The above is the PHP API syntax)


    Edit, checking http://freelancing-god.github.com/ts/en/searching.html and http://freelancing-god.github.com/ts/en/common_issues.html#or_attributes

    looks like might be something like

    with_display = "*, IF(@weight=>titles,1,0) AS display"
    Title.search 'search_key/3',
      :match_mode => :extended,
      :rank_mode => :wordcount,
      :sphinx_select => with_display,
      :with          => {'display' => 1}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello Ruby/Rails/Merb developers! Im currently working on a web project that will have a
This is not a ruby/rails project deploy. I have the following situation and I
I'm a new ruby/rails user trying to get my mac set up for the
how to make the ruby on rails with mysql environment in ubuntu 11.04. I
I have a Ruby/Rails app. I have an artists table in my postgresql database
I have the below table ID First Name Last Name 1 Ruby Rails 2
I've got an existing production Ruby/Rails app that I want to migrate to MongoDB
I installed Sphinx and Thinking Sphinx for ruby on rails 2.3.2. When I search
This ruby/rails construct always puzzles me: User.where(:name => Thiago).limit(3).using(:slave_one) This must execute from left-to-right,
I am looking for a Ruby/Rails tool that will help me accomplish the following:

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.