This new release enables indexing of the values stored inside the property hash.
You can simply index a given property:
class Contact < ActiveRecord::Base
include Property
property do |p|
p.string 'name', :indexed => true
end
end
Or you can build complex dynamic indices by using blocks, either on a single property or for a group of properties:
class Contact < ActiveRecord::Base
include Property
property do |p|
p.string 'name', :indexed => true
p.string 'first_name', :index => Proc.new {|rec| { 'fullname' => rec.fullname }}
p.index(:string) do |record|
{
'fulltext' => "name:#{record.name} first_name:#{record.first_name}",
"name_#{record.lang}" => record.name
}
end
end
end
You can even use a custom ActiveRecord class:
class Contact < ActiveRecord::Base
include Property
property do |p|
p.string 'name'
p.string 'first_name'
p.index(ContactIndex) do |record|
{
'name' => record.name,
'first_name' => record.first_name,
}
end
end
end
See property for details.
Gaspard Bucher
comments