[英]How to Boost a Field In Lucene.Net 3
我想在Lucene.Net 3.0.3中增加一个字段。 然而,SetBoost方法似乎不再在Lucene中定义。 我如何提升一个领域,比方说,我希望文档的“标题”能够承载其他领域的更多权重?
您可以在索引时间或搜索时间中增加字段。 要在索引时间中增加字段,您可以设置:
Field titleField = new Field("title", strTitle, Field.Store.NO, Field.Index.ANALYZED);
titleField.Boost = 2;
doc.Add(titleField);
请记住,OmitNorms必须设置为false。
要在搜索时间内增加字段,您可以设置:
TermQuery q = new TermQuery(new Term("title", "cat"));
q.Boost = 2;
_searcher.Search(q, 100);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.