Hi,
Using the 0.10.4 gem under ruby 1.8.5 (2006-08-25) [i686-linux], I
get different results with a TermQuery and a search string. Namely,
using a search string seems to always work whereas using a TermQuery
often doesn''t return any entries.
For example:
> x=@i[450][:message_id]
=> "9e7db9110509070759732b21c4 at mail.gmail.com"
> @i.search("message_id:#{x}")
=> #<struct Ferret::Search::TopDocs total_hits=1, hits=[#<struct
Ferret::Search::Hit doc=450, score=6.51688194274902>],
max_score=6.51688194274902>
> @i.search(Ferret::Search::TermQuery.new(:message_id, x))
=> #<struct Ferret::Search::TopDocs total_hits=0, hits=[],
max_score=0.0>
But sometimes it works fine:
> x=@i[123][:message_id]
=> "c715e64050831145815d9262c at mail.gmail.com"
> @i.search("message_id:#{x}")
=> #<struct Ferret::Search::TopDocs total_hits=1, hits=[#<struct
Ferret::Search::Hit doc=123, score=7.21260595321655>],
max_score=7.21260595321655>
> @i.search(Ferret::Search::TermQuery.new(:message_id, x))
=> #<struct Ferret::Search::TopDocs total_hits=1, hits=[#<struct
Ferret::Search::Hit doc=123, score=7.21260595321655>],
max_score=7.21260595321655>
So how come the first search doesn''t return anything?
FWIW, I am creating the index like this:
field_infos = Ferret::Index::FieldInfos.new :store => :yes
field_infos.add_field :message_id
# ...
field_infos.create_index dir
@i = Ferret::Index::Index.new(:path => dir)
Thanks for any help!
--
William <wmorgan-ferret at masanjin.net>