How to index a logical column in sphinx thinking using Ruby 1.8.7

I am new to ROR. I use the sphinx thinking. I need to index with one boolean field. that is, I list the active entries, this is true.

define_index do indexes car.name, :as => :car indexes car_model.car_make.name, :as => :car_make indexes city_name.city , :as=> :city_name indexes car_active, :as=>:is_active, :type=>:boolean, :default=>true end 

I need to list the details of the car that belong to the active one, that's true. Could you help me?

+4
source share
1 answer

If you want to filter a boolean, it is much better to have it as an attribute in Sphinx instead of a field. Fields are text data that people will search for, attributes are what you, as a developer, order and filter.

So, to configure this boolean column as an attribute:

 define_index do # fields indexes car.name, :as => :car indexes car_model.car_make.name, :as => :car_make indexes city_name.city , :as=> :city_name # attributes has car_active end 

And then filtering:

 Model.search 'foo', :with => {:car_active => true} 
+9
source

All Articles