Ruby on Rails Tuesday, November 30, 2010

Hi All,

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:
==========================

Model:
=====

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 => user.id, :game_id =>
gme.id, :date => dt})
end
end

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
end
end

Controller:
===========

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 = User.search '', :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 we have the data in database...
please help me on this.

query:
======
@results = User.search '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"

Which is not working or returns empty array set..


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


Thanks in Advance,
Jak.

--
Posted via http://www.ruby-forum.com/.

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment