Ruby Bharathrentals
2007-Apr-13 00:11 UTC
[Ferret-talk] 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 -- Posted via http://www.ruby-forum.com/.
Jens Kraemer
2007-Apr-13 07:32 UTC
[Ferret-talk] undefined method `ferret_index'' for xxx:Class
On Fri, Apr 13, 2007 at 02:11:35AM +0200, Ruby Bharathrentals 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 helpA 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 kraemer at webit.de | www.webit.de Amtsgericht Dresden | HRB 15422 GF Sven Haubold, Hagen Malessa
Chengcai He
2007-Apr-16 14:53 UTC
[Ferret-talk] undefined method `ferret_index'' for xxx:Class
Ruby Bharathrentals 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 > thanksI 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!!! -- Posted via http://www.ruby-forum.com/.
Jens Kraemer
2007-Apr-16 15:20 UTC
[Ferret-talk] undefined method `ferret_index'' for xxx:Class
On Mon, Apr 16, 2007 at 04:53:31PM +0200, Chengcai He wrote:> Ruby Bharathrentals 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 kraemer at webit.de | www.webit.de Amtsgericht Dresden | HRB 15422 GF Sven Haubold, Hagen Malessa
Ruby Bharathrentals
2007-Apr-17 01:49 UTC
[Ferret-talk] undefined method `ferret_index'' for xxx:Class
I found the answer; I had to use aaf_index.ferret_index instead of ferret_index thanks every one Ruby Bharathrentals 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-- Posted via http://www.ruby-forum.com/.