Index: trunk/gsdl/src/colservr/mgq.c
===================================================================
--- trunk/gsdl/src/colservr/mgq.c	(revision 333)
+++ trunk/gsdl/src/colservr/mgq.c	(revision 334)
@@ -12,4 +12,8 @@
 /*
    $Log$
+   Revision 1.7  1999/07/01 09:29:18  rjmcnab
+   Changes for better reporting of number documents which match a query. Changes
+   should still work as before with older versions of mg.
+
    Revision 1.6  1999/07/01 03:52:05  rjmcnab
    Added a function to get the equivalent terms of a query term. I also
@@ -608,4 +612,26 @@
 }
 
+/* gets the total number of documents retrieved. If this is not available */
+/* it will set total_retrieved to 0 (even when it obviously isn't) */
+int mgq_docsretrieved (int *total_retrieved, int *is_approx) {
+  query_data *qd = NULL;
+
+  if (cur_cachenum == -1) return 0;
+  qd = dbcache[cur_cachenum].qd;
+  if (qd == NULL || total_retrieved == NULL || is_approx == NULL) return 0;
+
+  /* set default values */
+  *total_retrieved = 0;
+  *is_approx = 0;
+
+  if (qd->DL == NULL) return 0;
+
+  *total_retrieved = qd->DL->total_retrieved;
+  *is_approx = qd->DL->is_approx;
+
+  return 0;
+}
+
+
 /* use mgq_getmaxstemlen to determine the length of the word stems to pass */
 /* to mgq_stemword */
Index: trunk/gsdl/src/colservr/mgq.h
===================================================================
--- trunk/gsdl/src/colservr/mgq.h	(revision 333)
+++ trunk/gsdl/src/colservr/mgq.h	(revision 334)
@@ -36,4 +36,8 @@
 int mgq_equivterms (unsigned char *wordstem, int (*sender)(char *, int, int, float, void *),
 		    void *ptr);
+
+/* gets the total number of documents retrieved. If this is not available */
+/* it will set total_retrieved to 0 (even when it obviously isn't) */
+int mgq_docsretrieved (int *total_retrieved, int *is_approx);
   
 /* use mgq_getmaxstemlen to determine the length of the word stems to pass */
Index: trunk/gsdl/src/colservr/mgsearch.cpp
===================================================================
--- trunk/gsdl/src/colservr/mgsearch.cpp	(revision 333)
+++ trunk/gsdl/src/colservr/mgsearch.cpp	(revision 334)
@@ -12,4 +12,8 @@
 /*
    $Log$
+   Revision 1.10  1999/07/01 09:29:19  rjmcnab
+   Changes for better reporting of number documents which match a query. Changes
+   should still work as before with older versions of mg.
+
    Revision 1.9  1999/07/01 03:54:48  rjmcnab
    Added code to plug in the equivalent terms of each of the query terms.
@@ -378,5 +382,5 @@
     setsearchmode (queryparams);
     submitquery (queryparams);
-    getresults (queryresults);
+    getresults (queryparams, queryresults);
     return true;
   }
@@ -445,18 +449,15 @@
 
 
-void mgsearchclass::getresults (queryresultsclass &queryresults)
-{
-  if (quotedquery[0] == '\0') 
-    { 
-      // don't need the text
-      mgq_results(result_docnums, 0, MAXNUMDOCS, 
-		  ourquerycallback, (void *)(&queryresults));
-    }
-  else
-    {
-      // we need the text for this one
-      mgq_results(result_docs, 0, MAXNUMDOCS, 
-		  ourquerycallback, (void *)(&queryresults));
-    }
+void mgsearchclass::getresults (const queryparamclass &queryparams,
+				queryresultsclass &queryresults) {
+  if (quotedquery[0] == '\0') { 
+    // don't need the text
+    mgq_results(result_docnums, 0, MAXNUMDOCS, 
+		ourquerycallback, (void *)(&queryresults));
+  } else {
+    // we need the text for this one
+    mgq_results(result_docs, 0, MAXNUMDOCS, 
+		ourquerycallback, (void *)(&queryresults));
+  }
   
   // get the term frequencies
@@ -468,4 +469,20 @@
   mgq_results(result_terms, 0, MAXNUMTERMS,
               termvariantscallback, (void *)(&queryresults));
+
+  // get the number of documents retrieved
+  int total_retrieved = 0, is_approx = 0;
+  mgq_docsretrieved (&total_retrieved, &is_approx);
+
+  if (total_retrieved == 0) {
+    // not available (or really was zero)
+    queryresults.docs_matched = queryresults.docs.size();
+    if (queryresults.docs_matched < queryparams.maxdocs)
+      queryresults.is_approx = true;
+    else
+      queryresults.is_approx = false;
+  } else {
+    queryresults.docs_matched = total_retrieved;
+    queryresults.is_approx = is_approx;
+  }
 }
 
Index: trunk/gsdl/src/colservr/mgsearch.h
===================================================================
--- trunk/gsdl/src/colservr/mgsearch.h	(revision 333)
+++ trunk/gsdl/src/colservr/mgsearch.h	(revision 334)
@@ -73,5 +73,5 @@
   void setsearchmode (const queryparamclass &queryparams);
   void submitquery (const queryparamclass &queryparams);
-  void getresults (queryresultsclass &queryresults);
+  void getresults (const queryparamclass &queryparams, queryresultsclass &queryresults);
 
   virtual void extractquoted (text_t &ttquerystring, text_t &ttquotedquery);
Index: trunk/gsdl/src/colservr/queryfilter.cpp
===================================================================
--- trunk/gsdl/src/colservr/queryfilter.cpp	(revision 333)
+++ trunk/gsdl/src/colservr/queryfilter.cpp	(revision 334)
@@ -12,4 +12,8 @@
 /*
    $Log$
+   Revision 1.9  1999/07/01 09:29:20  rjmcnab
+   Changes for better reporting of number documents which match a query. Changes
+   should still work as before with older versions of mg.
+
    Revision 1.8  1999/07/01 03:59:54  rjmcnab
    reduced MAXDOCS to 200 (more reasonable ???). I also added a virtual
@@ -389,5 +393,5 @@
   }
 
-  response.numDocs = queryresults.getnumdocs();
-  response.isApprox = (queryresults.getnumdocs() == queryparams.maxdocs);
-}
+  response.numDocs = queryresults.docs_matched;
+  response.isApprox = queryresults.is_approx;
+}
Index: trunk/gsdl/src/colservr/queryinfo.cpp
===================================================================
--- trunk/gsdl/src/colservr/queryinfo.cpp	(revision 333)
+++ trunk/gsdl/src/colservr/queryinfo.cpp	(revision 334)
@@ -12,4 +12,8 @@
 /*
    $Log$
+   Revision 1.6  1999/07/01 09:29:21  rjmcnab
+   Changes for better reporting of number documents which match a query. Changes
+   should still work as before with older versions of mg.
+
    Revision 1.5  1999/07/01 03:56:17  rjmcnab
    Added a set of utf8 encoded equivalent terms of a query term. I also
@@ -158,5 +162,4 @@
 
 void queryresultsclass::clear () {
-  docs_matched_set = false;;
   docs_matched = 0;
   is_approx = false;
@@ -170,5 +173,4 @@
 
 queryresultsclass &queryresultsclass::operator=(const queryresultsclass &q) {
-  docs_matched_set = q.docs_matched_set;
   docs_matched = q.docs_matched;
   is_approx = q.is_approx;
Index: trunk/gsdl/src/colservr/queryinfo.h
===================================================================
--- trunk/gsdl/src/colservr/queryinfo.h	(revision 333)
+++ trunk/gsdl/src/colservr/queryinfo.h	(revision 334)
@@ -107,5 +107,4 @@
   queryresultsclass () {clear();}
 
-  bool docs_matched_set;
   int docs_matched; // not available on all versions of mg
   bool is_approx;   // not available on all versions of mg
@@ -121,10 +120,4 @@
   queryresultsclass &operator=(const queryresultsclass &q);
   
-  int getnumdocs () {
-    if (docs_matched_set) return docs_matched;
-    else return docs.size();
-  }
-  int getnumterms () {return terms.size();}
-  
   void sortuniqqueryterms();
 };
