How to increase the field in Lucene.Net 3

I want to increase the field in Lucene.Net 3.0.3. However, the SetBoost method is no longer defined in Lucene. How to increase the field, say, I want the "Title" of the document to carry more weight than the rest of the field?

+4
source share
1 answer

You can increase the field in index time or during a search. To increase the 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 enlarge the field during the search, you can set:

  TermQuery q = new TermQuery(new Term("title", "cat")); q.Boost = 2; _searcher.Search(q, 100); 
+6
source

All Articles