Forum: Ferret undefined method `ferret_index' for xxx:Class

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.
6d6ee23eae2f986b4ed2024d666e18d1?d=identicon&s=25 Ruby Bharathrentals (bharathrentals)
on 2007-04-13 02:11
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
C9dd93aa135988cabf9183d3210665ca?d=identicon&s=25 Jens Kraemer (Guest)
on 2007-04-13 09:39
(Received via mailing list)
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 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
kraemer@webit.de | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
731a6662bbc6e0c82109e19686780214?d=identicon&s=25 Chengcai He (grandtang)
on 2007-04-16 16:53
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


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!!!
C9dd93aa135988cabf9183d3210665ca?d=identicon&s=25 Jens Kraemer (Guest)
on 2007-04-16 17:29
(Received via mailing list)
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@webit.de | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
6d6ee23eae2f986b4ed2024d666e18d1?d=identicon&s=25 Ruby Bharathrentals (bharathrentals)
on 2007-04-17 03:49
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
B03a63f9294524418ac4d486f567323c?d=identicon&s=25 Captain Feng (lumao66)
on 2007-04-27 09:54
Ruby Bharathrentals wrote:
> I found the answer; I had to use aaf_index.ferret_index instead of
> ferret_index
>
> thanks every one

God job!

captain
This topic is locked and can not be replied to.