Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/CrossCollectionSearch.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/CrossCollectionSearch.java	(revision 30149)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/CrossCollectionSearch.java	(revision 30150)
@@ -46,5 +46,7 @@
 	protected static final String QUERY_PARAM = "query";
 	protected static final String COLLECTION_PARAM = "collection";
-
+  protected static final String MAXDOCS_PARAM = "maxDocs"; // matches standard maxDocs, but in this case, means max docs per collection
+  protected static final String HITS_PER_PAGE_PARAM = "hitsPerPage";
+  protected static final String MAXDOCS_DEFAULT = "20";
 	// the services on offer - these proxy the actual collection ones
 	protected static final String TEXT_QUERY_SERVICE = "TextQuery";
@@ -88,5 +90,5 @@
 		{
 			// add in a default format statement
-			String format_string = "<format xmlns:gsf='" + GSXML.GSF_NAMESPACE + "' xmlns:xsl='" + GSXML.XSL_NAMESPACE + "'><gsf:template match='documentNode'><td><a><xsl:attribute name='href'>?a=d&amp;c=<xsl:value-of select='@collection'/>&amp;d=<xsl:value-of select='@nodeID'/><xsl:if test=\"@nodeType='leaf'\">&amp;sib=1</xsl:if>&amp;dt=<xsl:value-of select='@docType'/>&amp;p.a=q&amp;p.s=" + TEXT_QUERY_SERVICE + "&amp;p.c=";
+			String format_string = "<format xmlns:gsf='" + GSXML.GSF_NAMESPACE + "' xmlns:xsl='" + GSXML.XSL_NAMESPACE + "'><gsf:template match='documentNode'><td>poos<a><xsl:attribute name='href'>?a=d&amp;c=<xsl:value-of select='@collection'/>&amp;d=<xsl:value-of select='@nodeID'/><xsl:if test=\"@nodeType='leaf'\">&amp;sib=1</xsl:if>&amp;dt=<xsl:value-of select='@docType'/>&amp;p.a=q&amp;p.s=" + TEXT_QUERY_SERVICE + "&amp;p.c=";
 			if (this.cluster_name != null)
 			{
@@ -130,4 +132,7 @@
 				Element param = GSXML.createParameterDescription(doc, COLLECTION_PARAM, getTextString("param." + COLLECTION_PARAM, lang), GSXML.PARAM_TYPE_ENUM_MULTI, "all", coll_ids_list, coll_names_map.get(lang));
 				param_list.appendChild(param);
+				// max docs param
+				param = GSXML.createParameterDescription(doc, MAXDOCS_PARAM, getTextString("param." + MAXDOCS_PARAM, lang), GSXML.PARAM_TYPE_INTEGER, MAXDOCS_DEFAULT, null, null);
+				param_list.appendChild(param);
 				// query param
 				param = GSXML.createParameterDescription(doc, QUERY_PARAM, getTextString("param." + QUERY_PARAM, lang), GSXML.PARAM_TYPE_STRING, null, null, null);
@@ -176,5 +181,11 @@
 			}
 		}
-
+		
+		String maxdocs = MAXDOCS_DEFAULT;
+		Element maxdocs_param = GSXML.getNamedElement(param_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT, MAXDOCS_PARAM);
+		if (maxdocs_param != null) {
+		  maxdocs = GSXML.getValue(maxdocs_param);
+		}
+		
 		Document msg_doc = XMLConverter.newDOM();
 		Element query_message = msg_doc.createElement(GSXML.MESSAGE_ELEM);
@@ -198,36 +209,17 @@
 		query_request.appendChild(new_param_list);
 		new_param_list.appendChild(msg_doc.importNode(GSXML.getNamedElement(param_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT, QUERY_PARAM), true));
+
+		// for cross coll search, we only want maxdocs from each collection
+		// some colls use maxdocs, some use hits per page so lets send both
+		new_param_list.appendChild(GSXML.createParameter(msg_doc, MAXDOCS_PARAM, maxdocs));
+		new_param_list.appendChild(GSXML.createParameter(msg_doc, HITS_PER_PAGE_PARAM, maxdocs));
 		Element query_result = (Element) this.router.process(query_message);
 
-		// gather up the data from each response
-		int numDocsMatched = 0;
-		int numDocsReturned = 0;
-
-		//term info??
-
-		NodeList metadata = query_result.getElementsByTagName(GSXML.METADATA_ELEM);
-		for (int j = 0; j < metadata.getLength(); j++)
-		{
-			Element meta = (Element) metadata.item(j);
-			if (meta.getAttribute(GSXML.NAME_ATT).equals("numDocsReturned"))
-			{
-				numDocsReturned += Integer.parseInt(GSXML.getValue(meta));
-			}
-			else if (meta.getAttribute(GSXML.NAME_ATT).equals("numDocsMatched"))
-			{
-				numDocsMatched += Integer.parseInt(GSXML.getValue(meta));
-			}
-		}
-
-		Element metadata_list = result_doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
-		result.appendChild(metadata_list);
-		GSXML.addMetadata(metadata_list, "numDocsReturned", "" + numDocsReturned);
-		//GSXML.addMetadata(metadata_list, "numDocsMatched", ""+numDocsMatched);
-
+		// create the doc list for the response
 		Element doc_node_list = result_doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
 		result.appendChild(doc_node_list);
 
 		NodeList responses = query_result.getElementsByTagName(GSXML.RESPONSE_ELEM);
-
+		int num_docs = 0;
 		for (int k = 0; k < responses.getLength(); k++)
 		{
@@ -236,4 +228,5 @@
 			if (nodes == null || nodes.getLength() == 0)
 				continue;
+			num_docs += nodes.getLength();
 			Element last_node = null;
 			Element this_node = null;
@@ -258,4 +251,7 @@
 			}
 		}
+		// just send back num docs returned. Too hard to work out number of matches etc as each index type
+		// does it differently
+		GSXML.addMetadata(metadata_list, "numDocsReturned", "" + num_docs);
 		return result;
 	}
