Forum: Ferret Combine ferret with database

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.
Henrik Z. (Guest)
on 2007-02-22 20:26
(Received via mailing list)
Hello list,

I wonder if someone has some tips on joining a ferret search with a
database.

I have a rails project using a postgresql backend and I would like to
utilize the superb performance of ferret for fulltext searching.
The problem is that I have to joined the result with the database as
I have some user access rights to different documents to take into
account.

Does anyone have any ideas how to do this easily?

MAybe a cool stored procedure in PGSQL that can utilize the ferret
index :D

Cheers,
henrik
Ryan K. (Guest)
on 2007-02-22 21:22
(Received via mailing list)
On 2/22/07, Henrik Z. <removed_email_address@domain.invalid> wrote:
> account.
>
> Does anyone have any ideas how to do this easily?
>
> MAybe a cool stored procedure in PGSQL that can utilize the ferret
> index :D


Use acts_as_ferret [1], then either put the access rights stuff in the
index, or post process the results from AAF.

-ryan
1. http://projects.jkraemer.net/acts_as_ferret/wiki
Jens K. (Guest)
on 2007-02-23 12:09
(Received via mailing list)
Hi!

On Thu, Feb 22, 2007 at 10:38:59AM -0800, Ryan K. wrote:
> On 2/22/07, Henrik Z. <removed_email_address@domain.invalid> wrote:
> >
> >Hello list,
> >
> >I wonder if someone has some tips on joining a ferret search with a
> >database.
[..]
>
>
> Use acts_as_ferret [1], then either put the access rights stuff in the
> index, or post process the results from AAF.
>
> -ryan
> 1. http://projects.jkraemer.net/acts_as_ferret/wiki

to expand this a bit, with aaf you can combine a ferret query with
the usual active record conditions, joins and includes like that:

Model.find_by_contents(query, {}, { :conditions => ["... ], :include
=>... })

or just use find_id_by_contents to only retrieve id, model class and
score for each hit, and build your own AR query from that.

cheers,
Jens


--
Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
removed_email_address@domain.invalid | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
Henrik Z. (Guest)
on 2007-02-24 00:27
(Received via mailing list)
23 feb 2007 kl. 11:06 skrev Jens K.:

>>
>
> Model.find_by_contents(query, {}, { :conditions =>
> ["... ], :include =>... })
>
> or just use find_id_by_contents to only retrieve id, model class and
> score for each hit, and build your own AR query from that.
>
Hmm this is really interesting. It looks like this is exactly what I
want. I'll give it a try and see how it goes. Thanks for the info!

Cheers,
henrik
caman (Guest)
on 2007-02-27 06:50
Were you able to figure this out?
Would you share your approach or code?
send me an email to aboxfortheotherstuff at gmail dot com
Thanks
Henrik Z. wrote:
> 23 feb 2007 kl. 11:06 skrev Jens K.:
>
>>>
>>
>> Model.find_by_contents(query, {}, { :conditions =>
>> ["... ], :include =>... })
>>
>> or just use find_id_by_contents to only retrieve id, model class and
>> score for each hit, and build your own AR query from that.
>>
> Hmm this is really interesting. It looks like this is exactly what I
> want. I'll give it a try and see how it goes. Thanks for the info!
>
> Cheers,
> henrik
Henrik Z. (Guest)
on 2007-02-27 14:35
(Received via mailing list)
Hello again,

I haven't had the time to look at all the details yet. I've done some
testing on single tables and it works really good.
The problem is that I have a really really BIG sql query at the
moment which I run through find_by_sql so it will take me some time
to get that one working with find_by_contents.

I'll post any progress to this list.

Cheers,
henrik

27 feb 2007 kl. 05:50 skrev caman:
This topic is locked and can not be replied to.