我想提升 Lucene.Net 3.0.3 中的一个领域。然而,在 Lucene 中似乎不再定义 SetBoost 方法。我如何提升一个字段,例如,我希望文档的“标题”比其他字段更重要?
问问题
2967 次
1 回答
8
您可以在索引时间或搜索时间提升字段。要在索引时间中提升字段,您可以设置:
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);
于 2013-04-15T06:21:51.477 回答