Ruby Forum Ferret > Searcher Explain

Posted by James Harvey (jamesaharvey)
on 09.05.2008 16:53
(Received via mailing list)
Hi,

I am unable to use the Searcher's explain method.  Anytime I call it, I 
get
Segmentation Faults and it kills the process I have running my Rails 
site.
Has anyone else had this problem?  Here is some code I am trying to use 
it
in...

search = Search.create(:query => query)

@quotations = []

searcher = Ferret::Search::Searcher.new("index")  # FerretConfig::INDEX

bq = self.build_query(query)  # Builds a Boolean Query

searcher.search_each(bq) {|doc, score|
  @quotations << SearchResult.new(searcher[doc][:id],
searcher[doc][:quotation], searcher[doc][:author], score)
}

p searcher.explain(bq, @quotations[0].id).to_s

searcher.close




Thanks in advance for any help!

-James
Posted by Jens Kraemer (Guest)
on 13.05.2008 09:14
(Received via mailing list)
Hi!

On Fri, May 09, 2008 at 10:49:47AM -0400, James Harvey wrote:
> 
> bq = self.build_query(query)  # Builds a Boolean Query
> 
> searcher.search_each(bq) {|doc, score|
>   @quotations << SearchResult.new(searcher[doc][:id],
> searcher[doc][:quotation], searcher[doc][:author], score)
> }
> 
> p searcher.explain(bq, @quotations[0].id).to_s

If I get this right, @quotations[0].id will give the value of the id
field of that result, which is not a valid argument to explain. What the
explain method expects instead is the ferret-internal document id (the
doc value in your search_each block).

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
kraemer@webit.de | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold