Undefined method `ferret_index' for xxx:Class

Hi I am trying to use ferret; the regular search works; but when I use
the find_storage_by_contents to highlight the results, I am getting the
above error. Please help
thanks

On Fri, Apr 13, 2007 at 02:11:35AM +0200, Ruby B. wrote:

Hi I am trying to use ferret; the regular search works; but when I use
the find_storage_by_contents to highlight the results, I am getting the
above error. Please help

A stack trace really would help a lot to identify what’s the problem.

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
[email protected] | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa

Ruby B. wrote:

Hi I am trying to use ferret; the regular search works; but when I use
the find_storage_by_contents to highlight the results, I am getting the
above error. Please help
thanks

I alse got this exception when i use the highlight function following
the Acts_As_Ferret Tutorial on
http://www.railsenvy.com/2007/2/19/acts-as-ferret-tutorial

def find_storage_by_contents(query, options = {})
index = self.ferret_index # Get the index that acts_as_ferret created
for us
results = []

search_each is the core search function from Ferret, which

Acts_as_ferret hides
total_hits = index.search_each(query, options) do |doc, score|
result = {}

# Store each field in a hash which we can reference in our views
result[:name] = index.highlight(query, doc,
                :field => :name,
                :pre_tag => "<strong>",
                :post_tag => "</strong>",
                :num_excerpts => 1)
result[:author_name] = index.highlight(query, doc,
                :field => :author_name,
                :pre_tag => "<strong>",
                :post_tag => "</strong>",
                :num_excerpts => 1)
result[:score] = score   # We can even put the score in the hash, 

nice!

results.push result

end
return block_given? ? total_hits : [total_hits, results]
end

index = self.ferret_index # Get the index that acts_as_ferret created
for us

this line of code get some error! undefined method `ferret_index’!!!
Need help!!!

On Mon, Apr 16, 2007 at 04:53:31PM +0200, Chengcai He wrote:

Ruby B. wrote:

Hi I am trying to use ferret; the regular search works; but when I use
the find_storage_by_contents to highlight the results, I am getting the
above error. Please help
thanks

[…]

index = self.ferret_index # Get the index that acts_as_ferret created
for us

this line of code get some error! undefined method `ferret_index’!!!
Need help!!!

With the introduction of the DRb server things have become a bit more
complicated here. You can access the ferret index instance when running
locally (no DRb) with Model.aaf_index.ferret_index, however this is not
intended to work with a remote ferret server.

The good news is that aaf has it’s own highlight method that you can
call on every record that has been returned as a search result from aaf:

highlight_strings = record.highlight(query, options…)

Please see the api docs for a list of options.

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
[email protected] | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa

Ruby B. wrote:

I found the answer; I had to use aaf_index.ferret_index instead of
ferret_index

thanks every one

God job!

captain

I found the answer; I had to use aaf_index.ferret_index instead of
ferret_index

thanks every one

Ruby B. wrote:

Hi I am trying to use ferret; the regular search works; but when I use
the find_storage_by_contents to highlight the results, I am getting the
above error. Please help
thanks