Hey …
The QueryParser RDoc page explains to me on how to search for a specific
value in a specific field. This is not working the way i thought it
should be, what am i doing wrong? Here’s an example …
I’m storing model data in the index like this:
doc << Field.new( “object_id”, object.id, Field::Store::YES)
doc << Field.new( “type”, object.class.base_class.to_s,
Field::Store::YES)
This is working fine, i get something like this:
i[0]
=> Document {
stored/uncompressed,indexed,<object_id:3>
stored/uncompressed,indexed,type:Category
}
Now I want to search for all documents, with a specific type… here’s my
naive approach …
i.search_each(‘type:Category’) do |doc, score| puts “found #{doc}” end
=> 0
Searching for this will return my doc
i.search_each(‘object_id:3’) do |doc, score| puts “found #{doc}” end
found 0
=> 1
If I tokenize the ‘type’ field, my query is working, but I thought i can
store the value as-it by leaving it untokenized and am still able to
search for it with a FieldQuery. Am I wrong?
Thanks,
Ben