Ruby on Rails Tuesday, November 30, 2010

eugenio wrote in post #964246:
> I think you have to specify which fields ferret will index. Take a
> look at: (under "Usage").
> I got a lot of problems with ferret under production, you may consider
> switching to sphinx/thinking sphinx.

Hi thanks for the reply i tried sphinx, but i have following issue.

I am using rails 3.0 and i installed sphinx and added the following to
gemfile gem 'thinking-sphinx', '2.0.0', :require => 'thinking_sphinx'

My structure is like below:


class User < ActiveRecord::Base
include ActionView::Helpers::UrlHelper

has_one :profile, :class_name => "UserProfile", :dependent => :destroy

has_many :game_attributes, :dependent => :destroy do
def game(user, gme,dt)
find(:all, :conditions => {:user_id =>, :game_id =>, :date => dt})

has_and_belongs_to_many :interested_game,
:class_name => 'Game',
:join_table => 'interested_game_users',
:order => 'name'

define_index do
indexes login
indexes email
indexes admin
indexes staff
indexes game_attributes(:name), :as => :ga_name
indexes game_attributes.value, :as => :ga_value
indexes profile.gender, :as => :up_gender
has :id, created_at


Working query:
"rake ts:in RAILS_ENV=development
rake thinking_sphinx:rebuild RAILS_ENV=development
rake ts:start RAILS_ENV=development
rake ts:stop RAILS_ENV=development"
are working fine...

When i put this query " @results = '', :page =>
params[:page], :per_page => 10 " in controller, it producing the query,
i can able to see the results.

[1m[36mUser Load (0.1ms)[0m [1mSELECT `users`.* FROM `users` WHERE
(`users`.`id` IN (272, 275, 280, 281, 282, 283, 288, 289, 290, 291))[0m
@results [#<User
==============ThinkingSphinx::Search= length==== 10

When i try the below query it will not generate result or produces
empty result...... When i try this same query with rails db console it
producing the data, so we sure that have the data... please help me on

@results = 'j', :page => params[:page], :per_page => 10,
:conditions => {:ga_gender =>'Female', :login => 'Someusename',
:ga_name=> 'some name', ga_value=>'some value'}, star =>true, :sort_mode
=> :extended, :order => "created_at DESC"

2. How to implement delta to update thinkg-sphinx automatically for some
period / any document/forums , etc..

Thanks in Advance,

Posted via

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment