Apache Nutch is an extensible and scalable web crawler
NUTCH-775 Enhance Searcher interface
Sami Sirene136c0dccbbf
diff --git a/CHANGES.txt b/CHANGES.txtindex ed3faab96..a83cd4471 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -2,6 +2,8 @@ Nutch Change LogUnreleased Changes+* NUTCH-775 Enhance searcher interface (siren)+* NUTCH-781 Update Tika to v0.6 (jnioche)* NUTCH-269 CrawlDbReducer: OOME because no upper-bound on inlinks count (stack + jnioche)diff --git a/src/java/org/apache/nutch/searcher/DistributedSearchBean.java b/src/java/org/apache/nutch/searcher/DistributedSearchBean.javaindex 1fb2236a7..6ebaca53b 100644--- a/src/java/org/apache/nutch/searcher/DistributedSearchBean.java+++ b/src/java/org/apache/nutch/searcher/DistributedSearchBean.java@@ -49,10 +49,6 @@ public class DistributedSearchBean implements SearchBean {private int id;private Query query;- private int numHits;- private String dedupField;- private String sortField;- private boolean reverse;public SearchTask(int id) {this.id = id;@@ -62,16 +58,20 @@ public class DistributedSearchBean implements SearchBean {if (!liveServers[id]) {return null;}- return beans[id].search(query, numHits, dedupField, sortField, reverse);+ return beans[id].search(query);}+ /**+ * @deprecated since 1.1, use {@link #setSearchArgs(Query)} instead+ */public void setSearchArgs(Query query, int numHits, String dedupField,String sortField, boolean reverse) {this.query = query;- this.numHits = numHits;- this.dedupField = dedupField;- this.sortField = sortField;- this.reverse = reverse;+ query.setParams(new QueryParams(numHits, QueryParams.DEFAULT_MAX_HITS_PER_DUP, dedupField, sortField, reverse));+ }++ private void setSearchArgs(Query query) {+ this.query = query;}}@@ -199,12 +199,10 @@ public class DistributedSearchBean implements SearchBean {return beans[hit.getIndexNo()].getExplanation(query, hit);}- public Hits search(Query query, int numHits, String dedupField,- String sortField, boolean reverse) throws IOException {-+ @Override+ public Hits search(Query query) throws IOException {for (Callable<Hits> task : searchTasks) {- ((SearchTask)task).setSearchArgs(query, numHits, dedupField, sortField,- reverse);+ ((SearchTask)task).setSearchArgs(query);}List<Future<Hits>> allHits;@@ -216,10 +214,12 @@ public class DistributedSearchBean implements SearchBean {}PriorityQueue<Hit> queue; // cull top hits from results- if (sortField == null || reverse) {- queue = new PriorityQueue<Hit>(numHits);+ if (query.getParams().getSortField() == null+ || query.getParams().isReverse()) {+ queue = new PriorityQueue<Hit>(query.getParams().getNumHits());} else {- queue = new PriorityQueue<Hit>(numHits, new Comparator<Hit>() {+ queue = new PriorityQueue<Hit>(query.getParams().getNumHits(),+ new Comparator<Hit>() {public int compare(Hit h1, Hit h2) {return h2.compareTo(h1); // reverse natural order}@@ -251,7 +251,8 @@ public class DistributedSearchBean implements SearchBean {Hit newHit = new Hit(i, hit.getUniqueKey(),hit.getSortValue(), hit.getDedupValue());queue.add(newHit);- if (queue.size() > numHits) { // if hit queue overfull+ if (queue.size() > query.getParams().getNumHits()) {+ // if hit queue overfullqueue.remove();}}@@ -265,6 +266,15 @@ public class DistributedSearchBean implements SearchBean {return new Hits(totalHits, culledResults);}+ @Override+ @Deprecated+ public Hits search(Query query, int numHits, String dedupField,+ String sortField, boolean reverse) throws IOException {++ query.setParams(new QueryParams(numHits, QueryParams.DEFAULT_MAX_HITS_PER_DUP, dedupField, sortField, reverse));+ return search(query);+ }+public void close() throws IOException {executor.shutdown();pingService.shutdown();diff --git a/src/java/org/apache/nutch/searcher/IndexSearcher.java b/src/java/org/apache/nutch/searcher/IndexSearcher.javaindex 692ba25cc..850c1db2f 100644--- a/src/java/org/apache/nutch/searcher/IndexSearcher.java+++ b/src/java/org/apache/nutch/searcher/IndexSearcher.java@@ -89,18 +89,28 @@ public class IndexSearcher implements Searcher, HitDetailer {}}+ @Override+ @Deprecatedpublic Hits search(Query query, int numHits,String dedupField, String sortField, boolean reverse)throws IOException {+ query.setParams(new QueryParams(numHits,+ QueryParams.DEFAULT_MAX_HITS_PER_DUP, dedupField, sortField, reverse));+ return search(query);+ }++ @Override+ public Hits search(Query query) throws IOException {org.apache.lucene.search.BooleanQuery luceneQuery =this.queryFilters.filter(query);- return translateHits- (optimizer.optimize(luceneQuery, luceneSearcher, numHits,- sortField, reverse),- dedupField, sortField);+ return translateHits(optimizer.optimize(luceneQuery, luceneSearcher, query+ .getParams().getNumHits(), query.getParams().getSortField(), query+ .getParams().isReverse()), query.getParams().getDedupField(), query+ .getParams().getSortField());}+public String getExplanation(Query query, Hit hit) throws IOException {return luceneSearcher.explain(this.queryFilters.filter(query),Integer.valueOf(hit.getUniqueKey())).toHtml();diff --git a/src/java/org/apache/nutch/searcher/LuceneSearchBean.java b/src/java/org/apache/nutch/searcher/LuceneSearchBean.javaindex a3e93cfb0..f52290679 100644--- a/src/java/org/apache/nutch/searcher/LuceneSearchBean.java+++ b/src/java/org/apache/nutch/searcher/LuceneSearchBean.java@@ -78,10 +78,19 @@ public class LuceneSearchBean implements RPCSearchBean {}}++ @Override+ @Deprecatedpublic Hits search(Query query, int numHits, String dedupField,String sortField, boolean reverse)throws IOException {- return searcher.search(query, numHits, dedupField, sortField, reverse);+ query.setParams(new QueryParams(numHits, QueryParams.DEFAULT_MAX_HITS_PER_DUP, dedupField, sortField, reverse));+ return searcher.search(query);+ }++ @Override+ public Hits search(Query query) throws IOException {+ return searcher.search(query);}public String getExplanation(Query query, Hit hit) throws IOException {diff --git a/src/java/org/apache/nutch/searcher/NutchBean.java b/src/java/org/apache/nutch/searcher/NutchBean.javaindex 023b1c347..aa02e8db3 100644--- a/src/java/org/apache/nutch/searcher/NutchBean.java+++ b/src/java/org/apache/nutch/searcher/NutchBean.java@@ -151,86 +151,35 @@ HitInlinks, Closeable {return segmentBean.getSegmentNames();}+ /**+ * @deprecated since 1.1, use {@link #search(Query)} instead+ */public Hits search(Query query, int numHits) throws IOException {return search(query, numHits, null, null, false);}+ /**+ * @deprecated since 1.1, use {@link #search(Query)} instead+ */public Hits search(Query query, int numHits,String dedupField, String sortField, boolean reverse)throws IOException {- return searchBean.search(query, numHits, dedupField, sortField, reverse);- }-- @SuppressWarnings("serial")- private class DupHits extends ArrayList<Hit> {- private boolean maxSizeExceeded;- }-- /** Search for pages matching a query, eliminating excessive hits from the- * same site. Hits after the first <code>maxHitsPerDup</code> from the same- * site are removed from results. The remaining hits have {@link- * Hit#moreFromDupExcluded()} set. <p> If maxHitsPerDup is zero then all- * hits are returned.- *- * @param query query- * @param numHits number of requested hits- * @param maxHitsPerDup the maximum hits returned with matching values, or zero- * @return Hits the matching hits- * @throws IOException- */- public Hits search(Query query, int numHits, int maxHitsPerDup)- throws IOException {- return search(query, numHits, maxHitsPerDup, "site", null, false);+ query.getParams().initFrom(numHits, QueryParams.DEFAULT_MAX_HITS_PER_DUP, dedupField, sortField, reverse);+ return search(query);}-- /** Search for pages matching a query, eliminating excessive hits with- * matching values for a named field. Hits after the first- * <code>maxHitsPerDup</code> are removed from results. The remaining hits- * have {@link Hit#moreFromDupExcluded()} set. <p> If maxHitsPerDup is zero- * then all hits are returned.- *- * @param query query- * @param numHits number of requested hits- * @param maxHitsPerDup the maximum hits returned with matching values, or zero- * @param dedupField field name to check for duplicates- * @return Hits the matching hits- * @throws IOException- */- public Hits search(Query query, int numHits,- int maxHitsPerDup, String dedupField)- throws IOException {- return search(query, numHits, maxHitsPerDup, dedupField, null, false);- }- /** Search for pages matching a query, eliminating excessive hits with- * matching values for a named field. Hits after the first- * <code>maxHitsPerDup</code> are removed from results. The remaining hits- * have {@link Hit#moreFromDupExcluded()} set. <p> If maxHitsPerDup is zero- * then all hits are returned.- *- * @param query query- * @param numHits number of requested hits- * @param maxHitsPerDup the maximum hits returned with matching values, or zero- * @param dedupField field name to check for duplicates- * @param sortField Field to sort on (or null if no sorting).- * @param reverse True if we are to reverse sort by <code>sortField</code>.- * @return Hits the matching hits- * @throws IOException- */- public Hits search(Query query, int numHits,- int maxHitsPerDup, String dedupField,- String sortField, boolean reverse)- throws IOException {- if (maxHitsPerDup <= 0) // disable dup checking- return search(query, numHits, dedupField, sortField, reverse);++ @Override+ public Hits search(Query query) throws IOException {+ if (query.getParams().getMaxHitsPerDup() <= 0) // disable dup checking+ return searchBean.search(query);final float rawHitsFactor = this.conf.getFloat("searcher.hostgrouping.rawhits.factor", 2.0f);- int numHitsRaw = (int)(numHits * rawHitsFactor);+ int numHitsRaw = (int)(query.getParams().getNumHits() * rawHitsFactor);if (LOG.isInfoEnabled()) {LOG.info("searching for "+numHitsRaw+" raw hits");}- Hits hits = searchBean.search(query, numHitsRaw,- dedupField, sortField, reverse);+ Hits hits = searchBean.search(query);final long total = hits.getTotal();final Map<String, DupHits> dupToHits = new HashMap<String, DupHits>();final List<Hit> resultList = new ArrayList<Hit>();@@ -246,14 +195,13 @@ HitInlinks, Closeable {if (i == MAX_PROHIBITED_TERMS)break;optQuery.addProhibitedTerm(excludedValues.get(i),- dedupField);+ query.getParams().getDedupField());}numHitsRaw = (int)(numHitsRaw * rawHitsFactor);if (LOG.isInfoEnabled()) {LOG.info("re-searching for "+numHitsRaw+" raw hits, query: "+optQuery);}- hits = searchBean.search(optQuery, numHitsRaw,- dedupField, sortField, reverse);+ hits = searchBean.search(optQuery);if (LOG.isInfoEnabled()) {LOG.info("found "+hits.getTotal()+" raw hits");}@@ -273,7 +221,7 @@ HitInlinks, Closeable {dupToHits.put(value, dupHits = new DupHits());// does this hit exceed maxHitsPerDup?- if (dupHits.size() == maxHitsPerDup) { // yes -- ignore the hit+ if (dupHits.size() == query.getParams().getMaxHitsPerDup()) { // yes -- ignore the hitif (!dupHits.maxSizeExceeded) {// mark prior hits with moreFromDupExcluded@@ -292,7 +240,7 @@ HitInlinks, Closeable {// are we done?// we need to find one more than asked for, so that we can tell if// there are more hits to be shown- if (resultList.size() > numHits)+ if (resultList.size() > query.getParams().getNumHits())break;}}@@ -304,6 +252,73 @@ HitInlinks, Closeable {return results;}+ @SuppressWarnings("serial")+ private class DupHits extends ArrayList<Hit> {+ private boolean maxSizeExceeded;+ }++ /** Search for pages matching a query, eliminating excessive hits from the+ * same site. Hits after the first <code>maxHitsPerDup</code> from the same+ * site are removed from results. The remaining hits have {@link+ * Hit#moreFromDupExcluded()} set. <p> If maxHitsPerDup is zero then all+ * hits are returned.+ *+ * @param query query+ * @param numHits number of requested hits+ * @param maxHitsPerDup the maximum hits returned with matching values, or zero+ * @return Hits the matching hits+ * @throws IOException+ * @deprecated since 1.1, use {@link #search(Query)} instead+ *+ */+ public Hits search(Query query, int numHits, int maxHitsPerDup)+ throws IOException {+ return search(query, numHits, maxHitsPerDup, "site", null, false);+ }++ /** Search for pages matching a query, eliminating excessive hits with+ * matching values for a named field. Hits after the first+ * <code>maxHitsPerDup</code> are removed from results. The remaining hits+ * have {@link Hit#moreFromDupExcluded()} set. <p> If maxHitsPerDup is zero+ * then all hits are returned.+ *+ * @param query query+ * @param numHits number of requested hits+ * @param maxHitsPerDup the maximum hits returned with matching values, or zero+ * @param dedupField field name to check for duplicates+ * @return Hits the matching hits+ * @throws IOException+ * @deprecated since 1.1, use {@link #search(Query)} instead+ */+ public Hits search(Query query, int numHits,+ int maxHitsPerDup, String dedupField)+ throws IOException {+ return search(query, numHits, maxHitsPerDup, dedupField, null, false);+ }+ /** Search for pages matching a query, eliminating excessive hits with+ * matching values for a named field. Hits after the first+ * <code>maxHitsPerDup</code> are removed from results. The remaining hits+ * have {@link Hit#moreFromDupExcluded()} set. <p> If maxHitsPerDup is zero+ * then all hits are returned.+ *+ * @param query query+ * @param numHits number of requested hits+ * @param maxHitsPerDup the maximum hits returned with matching values, or zero+ * @param dedupField field name to check for duplicates+ * @param sortField Field to sort on (or null if no sorting).+ * @param reverse True if we are to reverse sort by <code>sortField</code>.+ * @return Hits the matching hits+ * @throws IOException+ * @deprecated since 1.1, use {@link #search(Query)} instead+ */+ public Hits search(Query query, int numHits,+ int maxHitsPerDup, String dedupField,+ String sortField, boolean reverse)+ throws IOException {+ query.setParams(new QueryParams(numHits, maxHitsPerDup, dedupField, sortField, reverse));+ return search(query);+ }+public String getExplanation(Query query, Hit hit) throws IOException {return searchBean.getExplanation(query, hit);@@ -374,9 +389,10 @@ HitInlinks, Closeable {final NutchBean bean = new NutchBean(conf);try {final Query query = Query.parse(args[0], conf);- final Hits hits = bean.search(query, 10);+ query.getParams().setMaxHitsPerDup(0);+ final Hits hits = bean.search(query);System.out.println("Total hits: " + hits.getTotal());- final int length = (int)Math.min(hits.getTotal(), 10);+ final int length = (int)Math.min(hits.getLength(), 10);final Hit[] show = hits.getHits(0, length);final HitDetails[] details = bean.getDetails(show);final Summary[] summaries = bean.getSummary(details, query);diff --git a/src/java/org/apache/nutch/searcher/Query.java b/src/java/org/apache/nutch/searcher/Query.javaindex 451d2ff31..710077253 100644--- a/src/java/org/apache/nutch/searcher/Query.java+++ b/src/java/org/apache/nutch/searcher/Query.java@@ -41,6 +41,16 @@ import org.apache.nutch.util.NutchConfiguration;public final class Query implements Writable, Cloneable, Configurable {public static final Log LOG = LogFactory.getLog(Query.class);+ private QueryParams params = new QueryParams();++ public void setParams(QueryParams context) {+ this.params = context;+ }++ public QueryParams getParams() {+ return params;+ }+/** A query clause. */public static class Clause implements Cloneable {public static final String DEFAULT_FIELD = "DEFAULT";@@ -362,6 +372,7 @@ public final class Query implements Writable, Cloneable, Configurable {out.writeByte(clauses.size());for (int i = 0; i < clauses.size(); i++)clauses.get(i).write(out);+ params.write(out);}public static Query read(DataInput in, Configuration conf) throws IOException {@@ -375,6 +386,8 @@ public final class Query implements Writable, Cloneable, Configurable {int length = in.readByte();for (int i = 0; i < length; i++)clauses.add(Clause.read(in, this.conf));++ params.readFields(in);}public String toString() {@@ -390,7 +403,7 @@ public final class Query implements Writable, Cloneable, Configurable {public boolean equals(Object o) {if (!(o instanceof Query)) return false;Query other = (Query)o;- return this.clauses.equals(other.clauses);+ return this.clauses.equals(other.clauses) && this.params.equals(other.params);}public int hashCode() {diff --git a/src/java/org/apache/nutch/searcher/QueryParams.java b/src/java/org/apache/nutch/searcher/QueryParams.javanew file mode 100644index 000000000..d33a5b141--- /dev/null+++ b/src/java/org/apache/nutch/searcher/QueryParams.java@@ -0,0 +1,138 @@+package org.apache.nutch.searcher;++import java.io.DataInput;+import java.io.DataOutput;+import java.io.IOException;++import org.apache.hadoop.io.Writable;+import org.apache.hadoop.io.WritableUtils;+import org.apache.nutch.metadata.Metadata;++/**+ * Query context object that describes the context of the query.+ */+public class QueryParams implements Writable {++ public static final String DEFAULT_DEDUP_FIELD = "site";+ public static final int DEFAULT_MAX_HITS_PER_DUP = 2;+ public static final int DEFAULT_NUM_HITS = 10;+ public static final boolean DEFAULT_REVERSE = false;++ private Metadata metadata = new Metadata();++ public void setNumHits(int numHits) {+ this.numHits = numHits;+ }++ public void setMaxHitsPerDup(int maxHitsPerDup) {+ this.maxHitsPerDup = maxHitsPerDup;+ }++ public void setDedupField(String dedupField) {+ this.dedupField = dedupField;+ }++ public void setSortField(String sortField) {+ this.sortField = sortField;+ }++ public void setReverse(boolean reverse) {+ this.reverse = reverse;+ }++ private int numHits;+ private int maxHitsPerDup;+ private String dedupField;+ private String sortField;+ private boolean reverse;++ public QueryParams() {+ setNumHits(DEFAULT_NUM_HITS);+ setMaxHitsPerDup(DEFAULT_MAX_HITS_PER_DUP);+ setDedupField(DEFAULT_DEDUP_FIELD);+ setSortField(sortField);+ setReverse(false);++ }++ public QueryParams(int numHits, int maxHitsPerDup, String dedupField,+ String sortField, boolean reverse) {+ initFrom(numHits, maxHitsPerDup, dedupField, sortField, reverse);+ }++ public void initFrom(int numHits, int maxHitsPerDup, String dedupField,+ String sortField, boolean reverse) {+ setNumHits(numHits);+ setMaxHitsPerDup(maxHitsPerDup);+ setDedupField(dedupField);+ setSortField(sortField);+ setReverse(reverse);+ }++ public int getNumHits() {+ return numHits;+ }++ public int getMaxHitsPerDup() {+ return maxHitsPerDup;+ }++ public String getDedupField() {+ return dedupField;+ }++ public String getSortField() {+ return sortField;+ }++ public boolean isReverse() {+ return reverse;+ }++ public String get(String name) {+ return metadata.get(name);+ }++ public void put(String name, String value) {+ metadata.set(name, value);+ }++ @Override+ public void readFields(DataInput input) throws IOException {+ metadata.readFields(input);+ numHits = WritableUtils.readVInt(input);+ maxHitsPerDup = WritableUtils.readVInt(input);+ dedupField = WritableUtils.readString(input);+ sortField = WritableUtils.readString(input);+ reverse = input.readBoolean();+ }++ @Override+ public void write(DataOutput output) throws IOException {+ metadata.write(output);+ WritableUtils.writeVInt(output, numHits);+ WritableUtils.writeVInt(output, maxHitsPerDup);+ WritableUtils.writeString(output, dedupField);+ WritableUtils.writeString(output, sortField);+ output.writeBoolean(reverse);+ }++ @Override+ public boolean equals(Object obj) {+ if (obj instanceof QueryParams) {++ QueryParams other = (QueryParams) obj;+ return other.numHits == this.numHits+ && other.metadata.equals(this.metadata)+ && other.reverse == this.reverse+ && other.maxHitsPerDup == this.maxHitsPerDup+ && ((other.dedupField != null && other.dedupField+ .equals(this.dedupField)) || (other.dedupField == null && this.dedupField == null))+ && ((other.sortField != null && other.sortField+ .equals(this.sortField)) || (other.sortField == null && this.sortField == null));++ } else {+ return false;+ }+ }+}diff --git a/src/java/org/apache/nutch/searcher/Searcher.java b/src/java/org/apache/nutch/searcher/Searcher.javaindex f9ab00b7d..d08c3e712 100644--- a/src/java/org/apache/nutch/searcher/Searcher.java+++ b/src/java/org/apache/nutch/searcher/Searcher.java@@ -23,10 +23,20 @@ import org.apache.hadoop.io.Closeable;/** Service that searches. */public interface Searcher extends Closeable {- /** Return the top-scoring hits for a query. */- Hits search(Query query, int numHits,- String dedupField, String sortField, boolean reverse)- throws IOException;+ /**+ * Return the top-scoring hits for a query.+ *+ * @deprecated since 1.1, use {@link #search(Query)} instead.+ * */+ Hits search(Query query, int numHits, String dedupField, String sortField,+ boolean reverse) throws IOException;++ /**+ * Return the top-scoring hits for a query.+ *+ * @since 1.1+ */+ Hits search(Query query) throws IOException;/** Return an HTML-formatted explanation of how a query scored. */String getExplanation(Query query, Hit hit) throws IOException;diff --git a/src/java/org/apache/nutch/searcher/SolrSearchBean.java b/src/java/org/apache/nutch/searcher/SolrSearchBean.javaindex 2c7cd950b..3adbb3fc9 100644--- a/src/java/org/apache/nutch/searcher/SolrSearchBean.java+++ b/src/java/org/apache/nutch/searcher/SolrSearchBean.java@@ -68,24 +68,23 @@ public class SolrSearchBean implements SearchBean {return "SOLR backend does not support explanations yet.";}- @SuppressWarnings("unchecked")- public Hits search(Query query, int numHits, String dedupField,- String sortField, boolean reverse)- throws IOException {-++ public Hits search(Query query) throws IOException {// filter query stringfinal BooleanQuery bQuery = filters.filter(query);final SolrQuery solrQuery = new SolrQuery(stringify(bQuery));- solrQuery.setRows(numHits);+ solrQuery.setRows(query.getParams().getNumHits());- if (sortField == null) {- solrQuery.setFields(dedupField, "score", searchUID);- sortField = "score";+ if (query.getParams().getSortField() == null) {+ solrQuery.setFields(query.getParams().getDedupField(), "score", searchUID);+ query.getParams().setSortField("score");} else {- solrQuery.setFields(dedupField, sortField, searchUID);- solrQuery.setSortField(sortField, reverse ? ORDER.asc : ORDER.desc);+ solrQuery.setFields(query.getParams().getDedupField(), query+ .getParams().getSortField(), searchUID);+ solrQuery.setSortField(query.getParams().getSortField(), query+ .getParams().isReverse() ? ORDER.asc : ORDER.desc);}QueryResponse response;@@ -101,7 +100,7 @@ public class SolrSearchBean implements SearchBean {for (int i = 0; i < hitArr.length; i++) {final SolrDocument solrDoc = docList.get(i);- final Object raw = solrDoc.getFirstValue(sortField);+ final Object raw = solrDoc.getFirstValue(query.getParams().getSortField());WritableComparable sortValue;if (raw instanceof Integer) {@@ -116,7 +115,7 @@ public class SolrSearchBean implements SearchBean {throw new RuntimeException("Unknown sort value type!");}- final String dedupValue = (String) solrDoc.getFirstValue(dedupField);+ final String dedupValue = (String) solrDoc.getFirstValue(query.getParams().getDedupField());final String uniqueKey = (String )solrDoc.getFirstValue(searchUID);@@ -126,6 +125,18 @@ public class SolrSearchBean implements SearchBean {return new Hits(docList.getNumFound(), hitArr);}+ @SuppressWarnings("unchecked")+ @Deprecated+ public Hits search(Query query, int numHits, String dedupField,+ String sortField, boolean reverse)+ throws IOException {+ query.getParams().setNumHits(numHits);+ query.getParams().setDedupField(dedupField);+ query.getParams().setSortField(sortField);+ query.getParams().setReverse(reverse);+ return search(query);+ }+public HitDetails getDetails(Hit hit) throws IOException {QueryResponse response;try {diff --git a/src/test/org/apache/nutch/searcher/QueryParamsTest.java b/src/test/org/apache/nutch/searcher/QueryParamsTest.javanew file mode 100644index 000000000..f7306031b--- /dev/null+++ b/src/test/org/apache/nutch/searcher/QueryParamsTest.java@@ -0,0 +1,15 @@+package org.apache.nutch.searcher;++import junit.framework.TestCase;++import org.apache.nutch.util.WritableTestUtils;++public class QueryParamsTest extends TestCase {++ public void testWritable() throws Exception {+ QueryParams context = new QueryParams(10, 2, "site", null, false);+ context.put("cat", "dog");+ WritableTestUtils.testWritable(context);+ }++}diff --git a/src/web/jsp/search.jsp b/src/web/jsp/search.jspindex 2463ea6d4..0fa129979 100644--- a/src/web/jsp/search.jsp+++ b/src/web/jsp/search.jsp@@ -204,8 +204,8 @@ function queryfocus() { document.search.query.focus(); }// position.... this is good, bad?... ugly?....Hits hits;try{- hits = bean.search(query, start + hitsToRetrieve, hitsPerSite, "site",- sort, reverse);+ query.getParams.initFrom(start + hitsToRetrieve, hitsPerSite, "site", sort, reverse);+ hits = bean.search(query);} catch (IOException e){hits = new Hits(0,new Hit[0]);}