[Ferret-talk] Two Shared Indices(sp?) in aaf.rb file (for Acts_as_ferret)
Philip Ingram
philip at prettybycritty.com
Sun Feb 1 16:04:28 EST 2009
Hi Jens,
No, but i didn't know that either, so thank you.
What i'm trying is to do the following, All of this code below is in
aaf.rb (hopefully the formatting shows up in this email).
ActsAsFerret::define_index('site_index',
:models => {
Product => {:fields => [:name, :company]},
Post => {:fields => [:title, :body]},
Prategory => {:fields => [:name]}
},
:ferret => {
:default_fields => [:name, :company, :title, :body, :name]
}
),
ActsAsFerret::define_index('forumindex',
:models => {
Topics => {:fields => [:title]},
Messages => {:fields => [:title, :content]}
},
:ferret => {
:default_fields => [:title, :title, :content]
}
)
Now, i get errors when i try to do this, but essentially i want to
somehow use 'site_Index' to search those models across all of my site,
and only 'forumindex' when i put the search fields on the forum.
IN my Search_controller.rb file i have:
def search
per_page = 15
@results = ActsAsFerret.find(params[:q], 'site_index', {:page =>
params[:page], :per_page => per_page}, :conditions => ["account_id
= ?", current_account.id] )
end
def forum
per_page = 30
@results = ActsAsFerret.find(params[:q], 'forumindex', {:page =>
params[:page], :per_page => per_page})
end
Notice that i have a condition statement for current_account's on
site_index. Am i doing this wrong? Is there a better way to add
conditions that i'm unaware of?
I do love the benefits of a shared index, but i'm wondering if more
then on index can be written at a time?
thoughts?
On 1-Feb-09, at 1:16 PM, Jens Krämer wrote:
> Hi,
>
> I'm not sure if this is what you're trying, but having the same
> model belong to two or more index is impossible with acts_as_ferret.
>
> Cheers,
> Jens
>
> On 01.02.2009, at 16:49, Philip Ingram wrote:
>
>> Hi all,
>>
>> I'm trying to add two shared indices to the aaf.rb file, however it
>> is not working. I currently have one shared index, but that index
>> has a condition on it, and i'm not sure how to go about creating
>> another index without this condition in it for my forum, which i
>> want to search only the forum, topics and messages.
>>
>> Within aaf.rb i tried to comma separate thecode: eg.g
>>
>> ActsAsFerret::define_index ('one'....), ActsAsFerret::define_index
>> ('two'....)
>>
>> To no avail.
>>
>> I also tried to add another aaf2.rb file to the original call when
>> aaf.rb, and include both of these files when aaf.rb is loaded but
>> no dice either.
>>
>> thoughts?
>> _______________________________________________
>> Ferret-talk mailing list
>> Ferret-talk at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/ferret-talk
>>
>
> --
> 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
>
>
>
> _______________________________________________
> Ferret-talk mailing list
> Ferret-talk at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ferret-talk
More information about the Ferret-talk
mailing list