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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:30:35+00:00 2026-05-26T23:30:35+00:00

In a typical Rails scenario where I only want the first and only one

  • 0

In a typical Rails scenario where I only want the first and only one record returned, I would say:

SomeModel.find(:first, :conditions => {:some_field => 'some_value'})

How would I ask this using thinking_sphinx? I’m supposing or hoping it would be something like:

SomeModel.search :conditions => {:limit => 'first', :some_field => some_value} 

However, I’m fairly certain this won’t work as it is just a wishful guess. Any clues?

  • 1 1 Answer
  • 1 View
  • 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-05-26T23:30:36+00:00Added an answer on May 26, 2026 at 11:30 pm

    Hm, I’m afraid it’s wrong way to compare searching by exact matching of looked up phrase (the first example) with full-text searching provided by Sphinx (the second one). While using the first query you are able to retrieve the only one first record with equal value to the searched one. And if you use Sphinx you pass a ranking function that defines what matching best suits for you (eg. if you give more keywords, then you can state whether you want to match all the keywords in each document, or only one keyword per document). If you want to read more about it, you can follow a link: http://sphinxsearch.com/blog/2010/08/17/how-sphinx-relevance-ranking-works/.

    However it’s possible to get the first matching value using thinking-sphinx, example:

    Article.search('sphinx relevance', :match_mode => :all).first
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Typical scenario: SomeModule.find(:all, :conditions [xyz = ?, some_var] SomeModule.find(:first, :conditions [xyz = ?, some_var]
i want to rebuild an app which is a typical rails 3.2 mvc app
Simple enough. When were making a typical restful rails app we would keep all
In a typical User - Post - Comment model in Rails, every user can
Typical approaches recommend reading the binary via FileStream and comparing it byte-by-byte. Would a
The typical Python threadpool will have a structure like this one: def run(self): while
I'm working on my first 'real' (as opposed to playing around) rails 3 project
Typical Event Log message looks like below. There you can find very interesting fields
I'm currently using RESTful Authentication plug-in on my rails application. There is a typical
I am switching to PostgreSQL from SQLite for a typical Rails application. The problem

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.