Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

Make query boosts configurable. Patch by Piotr Kosiorowski.

Douglass Cuttingbba90b836024
diff --git a/CHANGES.txt b/CHANGES.txt
index 6b90b50ac..6c9c94a93 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -70,6 +70,9 @@ Release 0.7
scoring by link count when generating fetchlists and searching.
(cutting, 20040419)
+15. Make query boosts for host, title, anchor and phrase matches
+ configurable. (Piotr Kosiorowski via cutting, 20050419)
+
Release 0.6
diff --git a/conf/nutch-default.xml b/conf/nutch-default.xml
index 128127180..8aeb41bec 100644
--- a/conf/nutch-default.xml
+++ b/conf/nutch-default.xml
@@ -669,4 +669,43 @@
</description>
</property>
+<!-- query-basic plugin properties -->
+
+<property>
+ <name>query.url.boost</name>
+ <value>4.0</value>
+ <description> Used as a boost for url field in Lucene query.
+ </description>
+</property>
+
+<property>
+ <name>query.anchor.boost</name>
+ <value>2.0</value>
+ <description> Used as a boost for anchor field in Lucene query.
+ </description>
+</property>
+
+
+<property>
+ <name>query.title.boost</name>
+ <value>1.5</value>
+ <description> Used as a boost for title field in Lucene query.
+ </description>
+</property>
+
+<property>
+ <name>query.host.boost</name>
+ <value>2.0</value>
+ <description> Used as a boost for host field in Lucene query.
+ </description>
+</property>
+
+<property>
+ <name>query.phrase.boost</name>
+ <value>1.0</value>
+ <description> Used as a boost for phrase in Lucene query.
+ Multiplied by boost for field phrase is matched in.
+ </description>
+</property>
+
</nutch-conf>
diff --git a/src/plugin/query-basic/src/java/org/apache/nutch/searcher/basic/BasicQueryFilter.java b/src/plugin/query-basic/src/java/org/apache/nutch/searcher/basic/BasicQueryFilter.java
index 697f5d1c4..db670775f 100644
--- a/src/plugin/query-basic/src/java/org/apache/nutch/searcher/basic/BasicQueryFilter.java
+++ b/src/plugin/query-basic/src/java/org/apache/nutch/searcher/basic/BasicQueryFilter.java
@@ -26,6 +26,7 @@ import org.apache.nutch.analysis.CommonGrams;
import org.apache.nutch.searcher.QueryFilter;
import org.apache.nutch.searcher.Query;
import org.apache.nutch.searcher.Query.*;
+import org.apache.nutch.util.NutchConf;
import java.io.IOException;
import java.util.HashSet;
@@ -33,14 +34,23 @@ import java.util.HashSet;
/** The default query filter. Query terms in the default query field are
* expanded to search the url, anchor and content document fields.*/
public class BasicQueryFilter implements QueryFilter {
+
+ private static float URL_BOOST =
+ NutchConf.get().getFloat("query.url.boost", 4.0f);
- private static float URL_BOOST = 4.0f;
- private static float ANCHOR_BOOST = 2.0f;
- private static float TITLE_BOOST = 1.5f;
- private static float HOST_BOOST = 2.0f;
+ private static float ANCHOR_BOOST =
+ NutchConf.get().getFloat("query.anchor.boost", 2.0f);
+
+ private static float TITLE_BOOST =
+ NutchConf.get().getFloat("query.title.boost", 1.5f);
+
+ private static float HOST_BOOST =
+ NutchConf.get().getFloat("query.host.boost", 2.0f);
private static int SLOP = Integer.MAX_VALUE;
- private static float PHRASE_BOOST = 1.0f;
+
+ private static float PHRASE_BOOST =
+ NutchConf.get().getFloat("query.phrase.boost", 1.0f);
private static final String[] FIELDS =
{ "url", "anchor", "content", "title", "host" };