From 6e9f4e90eb24a34dd130f912a0f20d4c9bdd07c6 Mon Sep 17 00:00:00 2001 From: bkoniden Date: Tue, 15 Mar 2011 17:02:53 +0000 Subject: [PATCH] Adding a query boost to the query. --- .../webapp/search/controller/PagedSearchController.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java index 94e7d0750..274ba26ee 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java @@ -97,6 +97,7 @@ public class PagedSearchController extends FreemarkerHttpServlet implements Sear private int defaultMaxSearchSize= 1000; protected static final Map> templateTable; + private static final float QUERY_BOOST = 2.0F; protected enum Format{ HTML, XML; @@ -229,7 +230,12 @@ public class PagedSearchController extends FreemarkerHttpServlet implements Sear try{ log.info("Searching for query term in the Index with maxHitSize "+ maxHitSize); 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){ log.error("in first pass at search: " + t); // this is a hack to deal with odd cases where search and index threads interact