Ignore:
Timestamp:
1999-07-01T21:29:21+12:00 (25 years ago)
Author:
rjmcnab
Message:

Changes for better reporting of number documents which match a query. Changes
should still work as before with older versions of mg.

Location:
trunk/gsdl/src/colservr
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/colservr/mgq.c

    r324 r334  
    1212/*
    1313   $Log$
     14   Revision 1.7  1999/07/01 09:29:18  rjmcnab
     15   Changes for better reporting of number documents which match a query. Changes
     16   should still work as before with older versions of mg.
     17
    1418   Revision 1.6  1999/07/01 03:52:05  rjmcnab
    1519   Added a function to get the equivalent terms of a query term. I also
     
    608612}
    609613
     614/* gets the total number of documents retrieved. If this is not available */
     615/* it will set total_retrieved to 0 (even when it obviously isn't) */
     616int mgq_docsretrieved (int *total_retrieved, int *is_approx) {
     617  query_data *qd = NULL;
     618
     619  if (cur_cachenum == -1) return 0;
     620  qd = dbcache[cur_cachenum].qd;
     621  if (qd == NULL || total_retrieved == NULL || is_approx == NULL) return 0;
     622
     623  /* set default values */
     624  *total_retrieved = 0;
     625  *is_approx = 0;
     626
     627  if (qd->DL == NULL) return 0;
     628
     629  *total_retrieved = qd->DL->total_retrieved;
     630  *is_approx = qd->DL->is_approx;
     631
     632  return 0;
     633}
     634
     635
    610636/* use mgq_getmaxstemlen to determine the length of the word stems to pass */
    611637/* to mgq_stemword */
  • trunk/gsdl/src/colservr/mgq.h

    r324 r334  
    3636int mgq_equivterms (unsigned char *wordstem, int (*sender)(char *, int, int, float, void *),
    3737            void *ptr);
     38
     39/* gets the total number of documents retrieved. If this is not available */
     40/* it will set total_retrieved to 0 (even when it obviously isn't) */
     41int mgq_docsretrieved (int *total_retrieved, int *is_approx);
    3842 
    3943/* use mgq_getmaxstemlen to determine the length of the word stems to pass */
  • trunk/gsdl/src/colservr/mgsearch.cpp

    r325 r334  
    1212/*
    1313   $Log$
     14   Revision 1.10  1999/07/01 09:29:19  rjmcnab
     15   Changes for better reporting of number documents which match a query. Changes
     16   should still work as before with older versions of mg.
     17
    1418   Revision 1.9  1999/07/01 03:54:48  rjmcnab
    1519   Added code to plug in the equivalent terms of each of the query terms.
     
    378382    setsearchmode (queryparams);
    379383    submitquery (queryparams);
    380     getresults (queryresults);
     384    getresults (queryparams, queryresults);
    381385    return true;
    382386  }
     
    445449
    446450
    447 void mgsearchclass::getresults (queryresultsclass &queryresults)
    448 {
    449   if (quotedquery[0] == '\0')
    450     {
    451       // don't need the text
    452       mgq_results(result_docnums, 0, MAXNUMDOCS,
    453           ourquerycallback, (void *)(&queryresults));
    454     }
    455   else
    456     {
    457       // we need the text for this one
    458       mgq_results(result_docs, 0, MAXNUMDOCS,
    459           ourquerycallback, (void *)(&queryresults));
    460     }
     451void mgsearchclass::getresults (const queryparamclass &queryparams,
     452                queryresultsclass &queryresults) {
     453  if (quotedquery[0] == '\0') {
     454    // don't need the text
     455    mgq_results(result_docnums, 0, MAXNUMDOCS,
     456        ourquerycallback, (void *)(&queryresults));
     457  } else {
     458    // we need the text for this one
     459    mgq_results(result_docs, 0, MAXNUMDOCS,
     460        ourquerycallback, (void *)(&queryresults));
     461  }
    461462 
    462463  // get the term frequencies
     
    468469  mgq_results(result_terms, 0, MAXNUMTERMS,
    469470              termvariantscallback, (void *)(&queryresults));
     471
     472  // get the number of documents retrieved
     473  int total_retrieved = 0, is_approx = 0;
     474  mgq_docsretrieved (&total_retrieved, &is_approx);
     475
     476  if (total_retrieved == 0) {
     477    // not available (or really was zero)
     478    queryresults.docs_matched = queryresults.docs.size();
     479    if (queryresults.docs_matched < queryparams.maxdocs)
     480      queryresults.is_approx = true;
     481    else
     482      queryresults.is_approx = false;
     483  } else {
     484    queryresults.docs_matched = total_retrieved;
     485    queryresults.is_approx = is_approx;
     486  }
    470487}
    471488
  • trunk/gsdl/src/colservr/mgsearch.h

    r325 r334  
    7373  void setsearchmode (const queryparamclass &queryparams);
    7474  void submitquery (const queryparamclass &queryparams);
    75   void getresults (queryresultsclass &queryresults);
     75  void getresults (const queryparamclass &queryparams, queryresultsclass &queryresults);
    7676
    7777  virtual void extractquoted (text_t &ttquerystring, text_t &ttquotedquery);
  • trunk/gsdl/src/colservr/queryfilter.cpp

    r327 r334  
    1212/*
    1313   $Log$
     14   Revision 1.9  1999/07/01 09:29:20  rjmcnab
     15   Changes for better reporting of number documents which match a query. Changes
     16   should still work as before with older versions of mg.
     17
    1418   Revision 1.8  1999/07/01 03:59:54  rjmcnab
    1519   reduced MAXDOCS to 200 (more reasonable ???). I also added a virtual
     
    389393  }
    390394
    391   response.numDocs = queryresults.getnumdocs();
    392   response.isApprox = (queryresults.getnumdocs() == queryparams.maxdocs);
    393 }
     395  response.numDocs = queryresults.docs_matched;
     396  response.isApprox = queryresults.is_approx;
     397}
  • trunk/gsdl/src/colservr/queryinfo.cpp

    r326 r334  
    1212/*
    1313   $Log$
     14   Revision 1.6  1999/07/01 09:29:21  rjmcnab
     15   Changes for better reporting of number documents which match a query. Changes
     16   should still work as before with older versions of mg.
     17
    1418   Revision 1.5  1999/07/01 03:56:17  rjmcnab
    1519   Added a set of utf8 encoded equivalent terms of a query term. I also
     
    158162
    159163void queryresultsclass::clear () {
    160   docs_matched_set = false;;
    161164  docs_matched = 0;
    162165  is_approx = false;
     
    170173
    171174queryresultsclass &queryresultsclass::operator=(const queryresultsclass &q) {
    172   docs_matched_set = q.docs_matched_set;
    173175  docs_matched = q.docs_matched;
    174176  is_approx = q.is_approx;
  • trunk/gsdl/src/colservr/queryinfo.h

    r326 r334  
    107107  queryresultsclass () {clear();}
    108108
    109   bool docs_matched_set;
    110109  int docs_matched; // not available on all versions of mg
    111110  bool is_approx;   // not available on all versions of mg
     
    121120  queryresultsclass &operator=(const queryresultsclass &q);
    122121 
    123   int getnumdocs () {
    124     if (docs_matched_set) return docs_matched;
    125     else return docs.size();
    126   }
    127   int getnumterms () {return terms.size();}
    128  
    129122  void sortuniqqueryterms();
    130123};
Note: See TracChangeset for help on using the changeset viewer.