# Searcher Explain

**URL:** <https://www.ruby-forum.com/t/searcher-explain/137168>\
**Category:** Ferret\
**Created:** [May 9, 2008, 4:53pm UTC](https://www.ruby-forum.com/t/searcher-explain/137168 "2008-05-09T16:53:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c57346/32.png) [@sjames](https://www.ruby-forum.com/u/sjames)\
**Post date:** [May 9, 2008, 4:53pm UTC](https://www.ruby-forum.com/t/searcher-explain/137168/1 "2008-05-09T16:53:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c57346/32.png) [@sjames](https://www.ruby-forum.com/u/sjames)\
**Post date:** [May 13, 2008, 9:14am UTC](https://www.ruby-forum.com/t/searcher-explain/137168/2 "2008-05-13T09:14:44Z")

</div>

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  
removed\_email\_address@domain.invalid | [www.webit.de](http://www.webit.de)

Amtsgericht Dresden | HRB 15422  
GF Sven Haubold
