MultiFieldQueryParser中的提升因子 [英] Boost factor in MultiFieldQueryParser

查看:89
本文介绍了MultiFieldQueryParser中的提升因子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用不同的因素来增强MultiFieldQueryParser中的不同字段吗? 另外,我可以分配给字段的最大提升因子值是什么?

Can I boost different fields in MultiFieldQueryParser with different factors? Also, what is the maximum boost factor value I can assign to a field?

非常感谢! 埃德

推荐答案

MultiFieldQueryParser具有一个[constructor] [1],可以接受增强映射.您可以将其与以下内容一起使用:

MultiFieldQueryParser has a [constructor][1] that accepts a map of boosts. You use it with something like this:

String[] fields = new String[] { "title", "keywords", "text" };
HashMap<String,Float> boosts = new HashMap<String,Float>();
boosts.put("title", 10);
boosts.put("keywords", 5);
MultiFieldQueryParser queryParser = new MultiFieldQueryParser(
    fields, 
    new StandardAnalyzer(),
    boosts
);

关于最大提升,我不确定,但是无论如何绝对不应该考虑提升.只需使用有意义的提升比例即可.另请参见此问题.

As for the maximum boost, I'm not sure, but you shouldn't think about boost in absolute terms anyway. Just use a ratio of boosts that makes sense. Also see this question.

[1]:

[1]: https://lucene.apache.org/core/4_4_0/queryparser/org/apache/lucene/queryparser/classic/MultiFieldQueryParser.html#MultiFieldQueryParser(org.apache.lucene.util.Version, java.lang.String[], org.apache.lucene.analysis.Analyzer, java.util.Map)

这篇关于MultiFieldQueryParser中的提升因子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆