[Ferret-talk] Two Shared Indices(sp?) in aaf.rb file (for Acts_as_ferret)
Jens Kraemer
jk at jkraemer.net
Tue Feb 10 04:03:33 EST 2009
Hi Phillip,
basically what you have there should work if you removed the comma
(aaf.rb is a standard ruby file, and each define_index call is just a
statement, so a newline or ';' is what you should use for separation
of these two calls).
If this doesn't help - what's the exact error you get (and when - at
application startup, when indexing or when searching?)
Cheers,
Jens
On 01.02.2009, at 22:04, Philip Ingram wrote:
> 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
>
> _______________________________________________
> Ferret-talk mailing list
> Ferret-talk at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ferret-talk
>
--
Jens Krämer
Finkenlust 14, 06449 Aschersleben, Germany
VAT Id DE251962952
http://www.jkraemer.net/ - Blog
http://www.omdb.org/ - The new free film database
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part
URL: <http://rubyforge.org/pipermail/ferret-talk/attachments/20090210/6299db7e/attachment.bin>
More information about the Ferret-talk
mailing list