TermQuery problem

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:

[email protected][450][:message_id]
=> “[email protected]
@i.search(“message_id:#{x}”)
=> #<struct Ferret::Search::TopDocs total_hits=1, hits=[#],
max_score=6.51688194274902>
@i.search(Ferret::Search::TermQuery.new(:message_id, x))
=> #

But sometimes it works fine:

[email protected][123][:message_id]
=> “[email protected]
@i.search(“message_id:#{x}”)
=> #<struct Ferret::Search::TopDocs total_hits=1, hits=[#],
max_score=7.21260595321655>
@i.search(Ferret::Search::TermQuery.new(:message_id, x))
=> #<struct Ferret::Search::TopDocs total_hits=1, hits=[#],
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!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs