[英]Lucene Query Boosting
I am reading 2 query from file like,我正在从文件中读取 2 个查询,例如,
Query q1 = new QueryParser(Version.LUCENE_CURRENT, "id", analyzer).parse(dis.readLine());
Query q2 = new QueryParser(Version.LUCENE_CURRENT, "id", analyzer).parse(dis.readLine());
I want these query to be combined as one query and give some boost (say by 5) to query 2 ie q2.我希望将这些查询组合为一个查询,并为查询 2 即 q2 提供一些提升(例如 5)。
Thanks,谢谢,
Ravi拉维
I believe this should work:我相信这应该有效:
q2.setBoost(5);
BooleanQuery q3 = new BooleanQuery();
q3.add(q1, BooleanClause.Occur.SHOULD);
q3.add(q2, BooleanClause.Occur.SHOULD);
You searching using the BooleanQuery
q3
.您使用BooleanQuery
q3
进行搜索。
I'm not sure if you can boost a query or not.我不确定您是否可以提升查询。 I know you can boost a field when you create the index eg我知道您可以在创建索引时提升字段,例如
Field field = new Field("id", id, ......);
field.setBoost(0.5);
As far as combining those 2 queries:至于结合这两个查询:
String term = dis.readLine() + " AND " + dis.readLine();
Or something to that effect.....或者类似的东西......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.