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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.