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

  • Home
  • SEARCH
  • 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 8263117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:59:20+00:00 2026-06-08T03:59:20+00:00

I have serious problem with Thinking Sphinx in my Rails application. My app specifications

  • 0

I have serious problem with Thinking Sphinx in my Rails application. My app specifications are as follows:

  • Rails 3.2.6
  • Ruby 1.9.3
  • Sphinx 2.0.4 (r3135)
  • Thinking Sphinx 2.0.12

In my application I have a Page model and a Offer model and pages have many offers. An index defined in the Page model looks like this:

define_index do

  #other indexes defined here
  #...

  has offers.width, as: :offers_width
  has offers.height, as: :offers_height
  has offers.price, as: :offers_price

  set_property delta: true
end

Then I’m doing a search on the Page model, where pages are selected based on search query and conditions. However, when I’m trying to use a :with filter, Sphinx gave me wrong results.

When I use only one filter, for example price or width, the results are OK, however when I’m trying to combine filters, like price and width, I’m getting results containing offers with the given price OR width, not price AND width.

When I’m searching with ranges, most of the time :with parameters are ranges rather than just integer values.

Edit 1
Query im using:

Page.search Riddle.escape(query), conditions: conditions, with: has_cond, star: true, per_page: Page.per_page, page: page

where has_cond is:

{:offers_height=>[175..200], :offers_width=>[175..200], :offers_price=>[10..80]}

It still gives me pages where ANY offer has height in that range or ANY offer has width in that range or same thing with price.

  • 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-08T03:59:23+00:00Added an answer on June 8, 2026 at 3:59 am

    Ok i found a solution. The reason sphinx gave me wrong results was because he was aggregating all offers inside single page. I had to move index from page to offers, and now query works as intended. My index in offer looks like this:

    define_index do
    
      indexes page(:description), as: :page_description
      indexes page(:address), as: :page_address
      indexes page(:title), as: :page_title
      indexes page(:status), as: :page_status
      indexes page.tags(:name), as: :page_tags_name
      indexes page.category(:id), as: :page_category_id
      indexes page.country(:id), as: :page_country_id
      indexes page(:verified), as: :page_verified
    
      has page(:id), as: :page_id
      has :width
      has :height
      has :price
    end
    

    I need to query sphinx first, and then do active record query.

    @sphinx_query = Offer.search Riddle.escape(query), with: has_cond, 
        conditions: conditions, group_function: :attr, group_by: 'page_id', 
        star: true, per_page: Page.per_page, page: page
    @pages = Page.find(@sphinx_query.map(&:page_id))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a serious problem in my app. I wrote a facebook like instant
I have got a serious problem running our web app in some machines.. machines
I have a roles model in a rails app that I have written a
I have a serious problem in my iphone application. It gets closed after entering
i have very serious problem if any tech expert can help...thank you in advance..
I have a serious problem. One of our servers crashed. Now I reinstalled the
I am new to python and I have a serious problem that I cannot
Ok guys, I have a serious problem with this. I have a static class
I am writing ESME using logica smpp lib , but have a serious problem
I have a serious performance problem. I have a database with (related to this

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.