[Ferret-talk] :single_index deprecated?
Jens Krämer
kraemer at webit.de
Mon Oct 13 12:11:33 EDT 2008
Hi!
On 10.10.2008, at 20:34, Chris G. wrote:
> I noticed that the :single_index option is no longer listed in the
> documentation for AAF, specifically in lib/acts_methods.rb [1]
>
> Furthermore, after an upgrade from a rather old version of AAF, I
> notice
> that the index (after reindexing) is no longer in
> RAILS_ROOT/index/RAILS_ENV/shared, but instead split out into separate
> directories for each model. What changed?
:single_index isn't supported any more.
With current trunk the preferred way to declare an index is via the
ActsAsFerret::define_index method, in a file called config/aaf.rb.
There you may declare several classes using the same index like this:
ActsAsFerret.define_index('my_index',
:models => {
OneModel => {
:fields => {
:title => { :boost => 2 },
:description => { }
},
:if => Proc.new { |r| r.published? }
},
AnotherModel => {
:fields => {
:title => { :boost => 2 },
:another_field => {},
},
:if => Proc.new { |r| r.should_index? }
}, :ferret => {
:default_field => %w( title description
another_field )
})
No need to call acts_as_ferret inside your model anymore (though it
will still work for the one index per class scenario).
my_index is the name of the index, to be used with ActsAsFerret::find:
ActsAsFerret::find("some query", 'my_index')
to only search records of a given class, find_with_ferret works as
expected:
OneModel.find_with_ferret('some query')
Sorry for not documenting this stuff better...
cheers,
Jens
--
Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49351467660 | Telefax +493514676666
kraemer at webit.de | www.webit.de
Amtsgericht Dresden | HRB 15422
GF Sven Haubold
More information about the Ferret-talk
mailing list