Forum: Ferret :single_index deprecated?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Chris G. (Guest)
on 2008-10-10 22:34
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?

Thanks,
-chris

[1] Notice it's still listed as an option here:
http://actsasferret.rubyforge.org/classes/ActsAsFe...
but not at
http://projects.jkraemer.net/acts_as_ferret/browse...
Jens Krämer (Guest)
on 2008-10-13 20:15
(Received via mailing list)
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
removed_email_address@domain.invalid | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold
Chris G. (Guest)
on 2008-10-14 00:19
(Received via mailing list)
Thanks for the update, Jens. Unfortunately, it looks like I'll have to
stick with the stable branch for now - these changes in trunk don't
jive well with my apps.

Thanks and keep up the great work!

-chris
This topic is locked and can not be replied to.