Adding a query boost to the query.

This commit is contained in:
bkoniden 2011-03-15 17:02:53 +00:00
parent 50eab74e48
commit 6e9f4e90eb

View file

@ -97,6 +97,7 @@ public class PagedSearchController extends FreemarkerHttpServlet implements Sear
private int defaultMaxSearchSize= 1000; private int defaultMaxSearchSize= 1000;
protected static final Map<Format,Map<Result,String>> templateTable; protected static final Map<Format,Map<Result,String>> templateTable;
private static final float QUERY_BOOST = 2.0F;
protected enum Format{ protected enum Format{
HTML, XML; HTML, XML;
@ -229,7 +230,12 @@ public class PagedSearchController extends FreemarkerHttpServlet implements Sear
try{ try{
log.info("Searching for query term in the Index with maxHitSize "+ maxHitSize); log.info("Searching for query term in the Index with maxHitSize "+ maxHitSize);
log.info("Query is "+ query.toString()); log.info("Query is "+ query.toString());
topDocs = searcherForRequest.search(query,null,maxHitSize);
//sets the query boost for the query. the lucene docs matching this query term
//are multiplied by QUERY_BOOST to get their total score
query.setBoost(QUERY_BOOST);
topDocs = searcherForRequest.search(query,null,maxHitSize);
}catch(Throwable t){ }catch(Throwable t){
log.error("in first pass at search: " + t); log.error("in first pass at search: " + t);
// this is a hack to deal with odd cases where search and index threads interact // this is a hack to deal with odd cases where search and index threads interact