Forum: Ruby on Rails FerretOnRails

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.
00e3a96684ab390a350b0271e98741d3?d=identicon&s=25 Nshbrown Nshbrown (nshb)
on 2006-02-28 18:12
(Received via mailing list)
I have spent a couple hours researching the FerretOnRails and
acts_as_ferret
plugin, and am very pleased with what I see so far.

My question is how to have my application, with multiple models:

Speakers
Talks
News
etc..

With all varying :string and :text column types, to be able to use a
single
index by which I can produce a search on.

I will go through each of the models and add a acts_as_ferret :fields =>
['text_field', 'string_field', 'etc'] for each of the models so they are
indexed. But as far as storing the data in a way so that I can query it
with
a single action like ActiveRecord::find_by_content('search query test'),
would work great. I even seen a reference to the previous post, but
haven't
yet figured out how to use this.

I read about the Typo integration, that has a Content model, which all
other
data models (Page, Comment, etc) extend and the
Content.find_by_content(@query) is used. This would work, however I do
not
want to have a "Core" model which is extended in that fashion. But
rather
have a acts_as_ferrett within each model, all referencing the same
index.
Then have one search page which queries them all, and links to the
controller/show/id for each record result.

Any ideas how I may use the acts_as_ferret to do this?

-Nb

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Nathaniel S. H. Brown                           http://nshb.net
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E48d29dc8fedb2878fa518d41cc63d88?d=identicon&s=25 Jan Prill (Guest)
on 2006-03-02 10:16
(Received via mailing list)
Hi, Nathaniel,

I don't remember it exactly but the last time I've looked into jkraemers
Typo integration of acts_as_ferret it was using reflection on the
indexed
model and stores the class_name as a field on the index while indexing.
Wouldn't then a query on your model 'x' that puts it's class-name in
your
query (besides the other fields of that model you want to search on) do
exactly what you want and find only xs because of that class-name?

Regards
Jan Prill
00e3a96684ab390a350b0271e98741d3?d=identicon&s=25 Nshbrown Nshbrown (nshb)
on 2006-03-02 13:16
(Received via mailing list)
Hey Jan,

The goal was to get a list of all the indexes without knowing what the
models/indexes are. Introspection of the sorts.

I had originally simplified it down to a configuration, which you can
use
Engine.add_index('Model'), and it will add that model into the search
when
visiting the search page. However, I have recently realised I can
introspect
the actual database, and do a
Object.const_get(table_name.pluralize).fields_for_ferrett to check if
there
is an index that "should" be created.

If so, then that model will get added. Haven't finalized this yet, but I
promise to release the FerretEngine once I have something a bit more
solidified.

Kind regards,
Nathan.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Nathaniel S. H. Brown                           http://nshb.net
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This topic is locked and can not be replied to.