Thanks for the quick reply. Sorry for my late reply i were "snowed in".

I tried your answer and i get the same result...


 Role Load (0.6ms)  SELECT "roles".* FROM "roles" WHERE "roles"."active" = 
> 'f'
>   Sphinx Query (1.3ms)  SELECT * FROM `person_core`, `person_delta` WHERE 
> `id` IN (304, 34, 306, 308, 334, 295, 344, 348, 352, 354, 365, 367, 308, 
> 429, 468, 9, 544, 590, 609, 110, 1643, 1652, 1653, 1655, 1669, 628, 1687, 
> 1691, 1709) AND `sphinx_deleted` = 0 ORDER BY `last_name` ASC, `first_name` 
> ASC LIMIT 0, 20 OPTION max_matches=10000
>   Sphinx  Found 1 results
>
>
 Is there other option(s)?

On Wednesday, February 12, 2014 6:54:06 PM UTC-5, Pat Allan wrote:
>
> Sphinx’s id is different to the model’s id. However, you can filter using 
> sphinx_internal_id instead: 
>
>     filters[:sphinx_internal_id] = rolepid 
>
> Unrelated, but the code in your controller can be simplified: 
>
>     if params[:active].present? 
>       roles = Role.find_all_by_active(params[:active]) 
>       filters[:sphinx_internal_id] = roles.collect &:person_id 
>     end 
>
> Or even better, use the pluck method, which grabs values straight from the 
> database and doesn’t instantiate Role instances: 
>
>     if params[:active].present? 
>       filters[:sphinx_internal_id] = 
> Role.find_all_by_active(params[:active]).pluck(:person_id) 
>     end 
>
> Cheers 
>
> — 
> Pat 
>
> On 13 Feb 2014, at 5:33 am, mamesaye kane <[email protected] <javascript:>> 
> wrote: 
>
> > Hi, 
> > 
> > When i search active it is not filtering result and doesn't give me 
> error. active is a field in another table (roles). rolepid is an array of 
> integer with the person ids. 
> > 
> > Why is it not returning the 29 records from rolepid array ? 
> > What am i missing? 
> > 
> > 
> > 
> > model 
> > class Person < ActiveRecord::Base 
> > 
> >   attr_accessible 
> > :alignment, :description, :first_name, : 
> > last_name 
> >   has_many 
> > :roles    #table roles with active as one of the field with value equal 
> t or f (boolean) 
> > end 
> >     
> > 
> > 
> > class Role < ActiveRecord::Base 
> > 
> >   attr_accessible 
> > :active, :organization_id, :person_id, : 
> > position_id 
> >   belongs_to 
> > : 
> > person 
> >   belongs_to 
> > : 
> > organization 
> >   belongs_to 
> > : 
> > position 
> > 
> > end   
> > 
> > person_index.rb 
> > 
> > 
> >  ThinkingSphinx::Index.define :person, :with => :active_record, :delta 
> => true do 
> > 
> > #Fields 
> >   indexes last_name, :sortable => true 
> >   indexes first_name, :sortable => true 
> >   indexes alignment 
> >   
> > #Attributes 
> >   has created_at, updated_at 
> >   has professions(:id), :as => :profession_ids 
> >   has positions(:id), :as => :position_id 
> >   has organizations(:id), :as => :organization_id 
> >   
> >   has '6', :as => :model_order, :type => :integer 
> > 
> > end 
> > 
> > 
> > people_controller 
> > 
> > if params[:active].present? 
> >   role = Array.new 
> >   rolepid = Array.new 
> >   role = Role.find_all_by_active(params[:active]) 
> >   role.each do |num| 
> >     rolepid << num.person_id 
> >   end 
> > end 
> > 
> > filters[:id] = rolepid if params[:active].present? 
> > 
> > @people = Person.search " #{params[:lastname]} #{params[:firstname]} 
> #{params[:alignment]}", 
> >   :with     => filters, 
> >   :star => true, 
> >   :condition =>  { :alignment => params[:alignment], }, #:lastname => 
> params[:lastname], :firstname => params[:firstname], 
> >   :order => 'last_name ASC, first_name ASC', 
> >   :page     => params[:page], 
> >   :per_page => 20 
> > 
> > 
> >   
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Thinking Sphinx" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected] <javascript:>. 
> > To post to this group, send email to 
> > [email protected]<javascript:>. 
>
> > Visit this group at http://groups.google.com/group/thinking-sphinx. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to