Jens,

    Thanks for the suggestion.  However, in this case the #ids field 
could contain a thousand ids, which I'm not sure is good.

    However, you just gave me another idea that involves 4 queries, but 
it doesn't seem to be working as it should.  Can you see why?

q = "chicken"

# lets get the total (where it's found in all the fields)
total = index.search_each(q) do |doc, score| end
puts "Total should be = #{total}"

# find count of just name results
query = qp.parse("+name:(#{q})")
puts query.to_s
total = index.search_each(query) do |doc, score| end
puts "total with name = #{total}"

# find all results where query is in ingredients but excluding the name 
results
query = qp.parse("+ingredients:(#{q}) -name:(#{q})")
puts query.to_s
total = index.search_each(query) do |doc, score| end
puts "total with ingredients = #{total}"

query = qp.parse("+tags:(#{q}) -name:(#{q}) -ingredients:(#{q})")
puts query.to_s
total = index.search_each(query) do |doc, score| end
puts "total with tags = #{total}"

query = qp.parse("+description:(#{q}) -name:(#{q}) -ingredients:(#{q}) 
-tags:(#{q})")
puts query.to_s
total = index.search_each(query) do |doc, score| end
puts "total with desc = #{total}"

    You would think that these fields would add up, but here are the 
results:

Total should be = 2225

name:chicken
total with name = 1028

+ingredients:chicken -name:chicken
total with ingredients = 2115

+tags:chicken -name:chicken -ingredients:chicken
total with tags = 18

+description:chicken -name:chicken -ingredients:chicken -tags:chicken
total with desc = 1

  As you can see, the numbers aren't adding up, but shouldn't they be?

  Thanks in advance for your help.



-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to