On Wed, Mar 21, 2007 at 10:56:42PM +0100, Henrik Zagerholm wrote:
> Hello list,
> 
> I have a little weird error when deleting documents from the index.
> 
> I'm using the following code.
> 
> ferret_index = Ferret::Index::Index.new(:path => FERRET_INDEX_PATH)
> query = Ferret::Search::TermQuery.new(:fk_file_id, "#{_fk_file_id}")
> ferret_index.search_each(query) do | id |
>       ferret_index.delete(id)
> end
> 
> And I get the following error
> Cannot delete for id of type Array
> 
> 
> As I see it the only way this could happened is if search_each  
> returns an Array of ID's but it couldn't right?

from the api docs:
search_each(query, options = {}) {|doc, score| ...}

you see that ferret hands you two arguments into the block.

Now if you only accept one parameter, Ruby guesses that you want 
all parameters as an array. This should yield a warning like 
'multiple values for a block parameter (2 for 1)' 
somewhere in your logs.

So just use |id, score| and everything should be fine :-)

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
[EMAIL PROTECTED] | www.webit.de
 
Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to