Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2FieldSearch.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2FieldSearch.java	(revision 29557)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2FieldSearch.java	(revision 29558)
@@ -328,5 +328,4 @@
 
 				addCustomQueryParams(param_list, lang);
-				createParameter(MAXDOCS_PARAM, param_list, lang);
 				if (!default_index_subcollection.equals(""))
 				{
@@ -338,4 +337,7 @@
 				}
 
+				if (does_chunking) {
+				  createParameter(MAXDOCS_PARAM, param_list, lang);
+				}
 				if (does_paging)
 				{
@@ -361,5 +363,4 @@
 			{
 				addCustomQueryParamsAdvField(param_list, lang);
-				createParameter(MAXDOCS_PARAM, param_list, lang);
 				if (!default_index_subcollection.equals(""))
 				{
@@ -394,4 +395,7 @@
 				{
 					createParameter(FIELD_ACCENT_PARAM, multiparam, lang);
+				}
+				if (does_chunking) {
+				  createParameter(MAXDOCS_PARAM, param_list, lang);
 				}
 				if (does_paging)
@@ -673,15 +677,19 @@
 
 		// add a metadata item to specify docs returned
-		int docs_returned = docs.length;
-		if (does_paging)
-		{
+		if (does_chunking) // this means we have a max docs param, and might ask for only a subset of results
+		{
+		  logger.error("does_chunking = true");
+		        int docs_returned = docs.length;
 			String maxdocs_str = (String) params.get(MAXDOCS_PARAM);
 			if (maxdocs_str != null)
 			{
 				int maxdocs = Integer.parseInt(maxdocs_str);
-				docs_returned = (maxdocs < (int) totalDocs ? maxdocs : (int) totalDocs);
-			}
-		}
-		GSXML.addMetadata(metadata_list, "numDocsReturned", "" + docs_returned);
+				if (maxdocs > 0) { // maxdocs==-1 means return all
+				  docs_returned = (maxdocs < (int) totalDocs ? maxdocs : (int) totalDocs);
+				}
+			}
+			GSXML.addMetadata(metadata_list, "numDocsReturned", "" + docs_returned);
+		}
+		
 
 		// add a metadata item to specify what actual query was done - eg if stuff was stripped out etc. and then we can use the query later, cos we don't know which parameter was the query
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2TextSearch.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2TextSearch.java	(revision 29557)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2TextSearch.java	(revision 29558)
@@ -117,5 +117,5 @@
 
 		// do we support any of the extended features?
-		does_chunking = true;
+		//does_chunking = true;
 
 		// Get the default index out of <defaultIndex> (buildConfig.xml)
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractSearch.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractSearch.java	(revision 29557)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractSearch.java	(revision 29558)
@@ -28,4 +28,5 @@
 import org.greenstone.gsdl3.util.GSPath;
 import org.greenstone.gsdl3.util.GSXML;
+import org.greenstone.gsdl3.util.XMLConverter;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -76,4 +77,5 @@
 	protected String default_index = "";
 
+  protected Element service_metadata_list = null;
   protected HashMap<String, String> paramDefaults = null;
 
@@ -81,7 +83,4 @@
 	{
 	  paramDefaults = new HashMap<String, String>();
-	  paramDefaults.put(MAXDOCS_PARAM, "100");
-	  paramDefaults.put(HITS_PER_PAGE_PARAM, "20");
-	  paramDefaults.put(START_PAGE_PARAM, "1");
 	}
 
@@ -111,4 +110,13 @@
 		tq_service.setAttribute(GSXML.NAME_ATT, QUERY_SERVICE);
 		this.short_service_info.appendChild(tq_service);
+
+		// load up paging defaults
+		if (does_chunking) {
+		  paramDefaults.put(MAXDOCS_PARAM, "100");
+		}
+		if (does_paging) {
+		  paramDefaults.put(HITS_PER_PAGE_PARAM, "20");
+		  paramDefaults.put(START_PAGE_PARAM, "1");
+		}
 
 		// load up any search param defaults
@@ -208,4 +216,15 @@
 			tq_service.appendChild(param_list);
 		}
+		if (subset == null || subset.equals(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER)) {
+
+		  if (service_metadata_list == null) {
+		    Document ml_doc = XMLConverter.newDOM();
+		    service_metadata_list = ml_doc.createElement(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
+		    if (does_paging) {
+		      service_metadata_list.appendChild(GSXML.createMetadataElement(ml_doc, "does_paging", "true"));
+		    }
+		  }
+		  tq_service.appendChild(doc.importNode(service_metadata_list, true));
+		}
 		return tq_service;
 
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/FedoraSearch.java.tmp
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/FedoraSearch.java.tmp	(revision 29557)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/FedoraSearch.java.tmp	(revision 29558)
@@ -91,5 +91,4 @@
 	tq_service.setAttribute(GSXML.NAME_ATT, QUERY_SERVICE);
 	this.short_service_info.appendChild(tq_service);
-	//does_paging = true;
 	
 	// add some format info to service map if there is any
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2LuceneSearch.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2LuceneSearch.java	(revision 29557)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2LuceneSearch.java	(revision 29558)
@@ -41,4 +41,5 @@
 public class GS2LuceneSearch extends SharedSoleneGS2FieldSearch
 {
+
   protected static final String SORT_ORDER_PARAM = "reverseSort";
   protected static final String SORT_ORDER_REVERSE = "1";
@@ -51,4 +52,5 @@
 	public GS2LuceneSearch()
 	{
+	  does_paging = true;
 		paramDefaults.put(SORT_ORDER_PARAM, SORT_ORDER_NORMAL);
 		this.lucene_src = new GS2LuceneQuery();
@@ -98,4 +100,5 @@
     
   }
+   
 	/** methods to handle actually doing the query */
 
@@ -108,9 +111,9 @@
 		String physical_index_language_name = null;
 		String physical_sub_index_name = null;
-		int maxdocs = Integer.parseInt(paramDefaults.get(MAXDOCS_PARAM));
 		int hits_per_page = Integer.parseInt(paramDefaults.get(HITS_PER_PAGE_PARAM));
 		int start_page = Integer.parseInt(paramDefaults.get(START_PAGE_PARAM));
 		String sort_field = getLuceneSort(default_sort);
 		String sort_order = paramDefaults.get(SORT_ORDER_PARAM);
+	       
 		// set up the query params
 		Set entries = params.entrySet();
@@ -122,11 +125,11 @@
 			String value = (String) m.getValue();
 
-			if (name.equals(MAXDOCS_PARAM) && !value.equals(""))
-			{
-				maxdocs = Integer.parseInt(value);
-			}
-			else if (name.equals(HITS_PER_PAGE_PARAM))
-			{
-				hits_per_page = Integer.parseInt(value);
+			if (name.equals(HITS_PER_PAGE_PARAM))
+			{
+			  if (value.equals("all")) {
+			    hits_per_page = -1;
+			  } else {
+			    hits_per_page = Integer.parseInt(value);
+			  }
 			}
 			else if (name.equals(START_PAGE_PARAM))
@@ -177,9 +180,12 @@
 		// set up start and end results if necessary
 		int start_results = 1;
-		if (start_page != 1)
+		if (start_page > 1 && hits_per_page > 0)
 		{
 			start_results = ((start_page - 1) * hits_per_page) + 1;
 		}
-		int end_results = hits_per_page * start_page;
+		int end_results = Integer.MAX_VALUE;
+		if (hits_per_page > 0) {
+		  end_results = hits_per_page * start_page;
+		}
 		this.lucene_src.setStartResults(start_results);
 		this.lucene_src.setEndResults(end_results);
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2MGPPSearch.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2MGPPSearch.java	(revision 29557)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2MGPPSearch.java	(revision 29558)
@@ -53,4 +53,5 @@
 	public GS2MGPPSearch()
 	{
+	  does_chunking = true;
 		if (mgpp_src == null)
 		{
@@ -90,4 +91,6 @@
 		mgpp_src.setReturnTerms(true);
 		mgpp_src.setMaxNumeric(this.maxnumeric);
+		// mgpp internal default is 50, so set it here so the interface params agree
+		paramDefaults.put(MAXDOCS_PARAM, "50");
 		return true;
 	}
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2MGSearch.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2MGSearch.java	(revision 29557)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2MGSearch.java	(revision 29558)
@@ -56,4 +56,5 @@
     /** constructor */
     public GS2MGSearch () {
+        does_chunking = true;
 	if(this.mg_src == null){
 	    this.mg_src = new MGSearchWrapper ();
@@ -70,6 +71,7 @@
             return false;
         }
-        
         this.mg_src.setMaxNumeric (this.maxnumeric);
+	// internally mg uses 50, so set this here
+	paramDefaults.put(MAXDOCS_PARAM, "50");
         return true;
     }
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GoogleNgramMGPPSearch.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GoogleNgramMGPPSearch.java	(revision 29557)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GoogleNgramMGPPSearch.java	(revision 29558)
@@ -31,5 +31,5 @@
 /**
  *
- * @author <a href="mailto:shaoqun@cs.waikato.ac.nz">Shaoqun Wu</a>
+ * @author Shaoqun Wu
  */
 
@@ -42,5 +42,5 @@
     /** constructor */
     public GoogleNgramMGPPSearch(){
-	super();	
+	this.does_paging = true;
     }
     
@@ -54,5 +54,4 @@
 	this.default_hits_per_page = "30";
         this.does_stem = false;
-	this.does_paging = true;
 	return true;
     }
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GoogleSearch.java.tmp
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GoogleSearch.java.tmp	(revision 29557)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GoogleSearch.java.tmp	(revision 29558)
@@ -56,4 +56,6 @@
     public GoogleSearch()
     {
+	does_paging = true;
+	does_chunking = false;
       QUERY_SERVICE = "TextQuery";
     }
@@ -78,6 +80,4 @@
 	}
 	
-	does_paging = true;
-	does_chunking = false;
 
 	// are we behind a proxy??
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/IViaSearch.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/IViaSearch.java	(revision 29557)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/IViaSearch.java	(revision 29558)
@@ -41,4 +41,6 @@
     public IViaSearch()
     {
+	does_paging = true;
+	does_multi_index_search = true;
     }
     
@@ -60,6 +62,4 @@
 	    return false;
 	}
-	does_paging = true;
-	does_multi_index_search = true;
 	this.default_index = ",kw,au,su,ti,de,fu,"; // all of them
 	index_ids = new ArrayList<String>();
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/SharedSoleneGS2FieldSearch.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/SharedSoleneGS2FieldSearch.java	(revision 29557)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/SharedSoleneGS2FieldSearch.java	(revision 29558)
@@ -49,5 +49,7 @@
 	public SharedSoleneGS2FieldSearch()
 	{
-	  super();
+		does_paging = true;
+		does_chunking = false; // actually it can but we don't want to do a max docs, as we are already paging results
+
 		// Lucene/Solr uses double operators, not single
 		//AND_OPERATOR = "&&";
@@ -57,6 +59,4 @@
 		NOT_OPERATOR = "NOT";
 
-		does_paging = true;
-		does_chunking = true;
 	}
 
