I want to boost a field in Lucene.Net 3.0.3. However the SetBoost Method doesnt appear to be defined anymore in Lucene. How do I boost a field, say, I want the "Title" of a document to carry more weight that the rest of the fields?
You can boost a field in index time or in search time. To boost a field in index time you can set:
Field titleField = new Field("title", strTitle, Field.Store.NO, Field.Index.ANALYZED);
titleField.Boost = 2;
doc.Add(titleField);
remember that OmitNorms must be set to false.
To boost a field in search time you can set:
TermQuery q = new TermQuery(new Term("title", "cat"));
q.Boost = 2;
_searcher.Search(q, 100);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With