On 8/1/06, Sam Giffney <[EMAIL PROTECTED]> wrote: > I'm making a simple business directory search and I want to boost the > relevance of the 'name' field over the 'address' field - both stored in > the same document in the same index. > > Here is some console code to demonstrate what I am actually doing > > >> include Ferret::Document > => Object > >> doc = Document.new > => Document { > } > >> doc << Field.new(:name, "Business Search", Field::Store::YES, > >> Field::Index::TOKENIZED, Field::TermVector::NO, false, 2.0) > => nil > >> doc << Field.new("physical_address", "New Zealand", Field::Store::YES, > >> Field::Index::TOKENIZED, Field::TermVector::NO, false, 1.0) > => nil > >> doc > => Document { > stored/uncompressed,indexed,tokenized,<name:Business Search> > stored/uncompressed,indexed,tokenized,<physical_address:New Zealand> > } > > I realise the docs say: "Note: this value is not stored directly with > the document in the index." so I guess that's why the boost field isn't > shown here.
The boost isn't shown here simple because I forgot to add it. It is stored with the document when you create it. However, it isn't stored with the document in the index. It is stored in a "norms" file. There is a norms file for every indexed field in the index (unless you chose Field::Index::OMIT_NORMS) and the norms file contains a single byte for every document in the index. > However, browsing the index in Luke shows that the boost value on each > field is still set to the default 1.0. Also empirical testing suggests > the boost value I'm entering isn't taken into account at all. I'm not sure why it doesn't show up in Luke. The boost is definitely working. I'm not sure what kinds of empirical tests you did. Try this; require 'rubygems' require 'ferret' include Ferret::Index include Ferret::Document index = Index.new doc = Document.new doc << Field.new(:name, "Business Search", Field::Store::YES, Field::Index::TOKENIZED, Field::TermVector::NO) index << doc doc.field(:name).boost = 2.0 index << doc puts "Explanation for Doc 0" puts index.explain("business", 0) puts "" puts "Explanation for Doc 1" puts index.explain("business", 1) The explain method explains the score for a query and a particular document. You'll notice the score is doubled for the second document. Hope that helps, Dave PS: anyone interested in porting Luke to ruby? Luke won't work on future versions of the Ferret index. I'd be happy to help out but I don't have time to do it by myself. _______________________________________________ Ferret-talk mailing list Ferret-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/ferret-talk