Changeset 393 for trunk/gsdl/src/colservr
- Timestamp:
- 1999-07-16T12:12:47+12:00 (25 years ago)
- Location:
- trunk/gsdl/src/colservr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/colservr/mgsearch.cpp
r350 r393 12 12 /* 13 13 $Log$ 14 Revision 1.13 1999/07/16 00:12:46 sjboddie 15 removed all the old post-processing stuff 16 14 17 Revision 1.12 1999/07/07 06:17:47 rjmcnab 15 18 broke search_index into index+subcollection+language … … 102 105 ///////////// 103 106 104 static char *quotedquery = NULL;105 static int casefold;106 107 107 static char *tempdoc = NULL; 108 108 static int templen = 0; … … 152 152 // it assumes that cache_num is set up correctly to point to 153 153 // a suitable result cache 154 int ourquerycallback(char * UDoc, int /*ULen*/, int DocNum,154 int ourquerycallback(char */*UDoc*/, int /*ULen*/, int DocNum, 155 155 float Weight, void *info) { 156 156 157 157 158 158 queryresultsclass *queryresults = (queryresultsclass * )info; 159 160 // check the returned document for the presence of the161 // quoted part of the query, if there was one162 163 // if (UDoc != NULL && quotedquery != NULL &&164 // quotedquery[0] != '\0' && strstr (UDoc, quotedquery) == NULL) return 0;165 166 167 if (UDoc != NULL && quotedquery != NULL && quotedquery[0] != '\0') {168 169 if (casefold) {170 int len;171 for (len = 0; quotedquery[len] != '\0'; len ++)172 quotedquery[len] = tolower (quotedquery[len]);173 for (len = 0; UDoc[len] != '\0'; len ++)174 UDoc[len] = tolower (UDoc[len]);175 }176 if (strstr (UDoc, quotedquery) == NULL) return 0;177 }178 159 179 160 // append this entry to the document results … … 277 258 static text_t getindexsuffix (const text_t &collection, 278 259 const text_t &index) { 279 text_t indexsuffix = "index"; 260 261 text_t indexsuffix = "index"; 262 // temporary hack so old version of niupepa collection 263 // can stay up until new one's finished 264 if (collection == "niupepa") indexsuffix = "index.new"; 265 280 266 indexsuffix = filename_cat (indexsuffix, index); 281 267 indexsuffix = filename_cat (indexsuffix, collection); … … 386 372 // the database was loaded) 387 373 if (queryhere == queryend) return true; 388 389 casefold = queryparams.casefolding;390 374 391 375 if (makeindexcurrent (queryparams.index, queryparams.subcollection, … … 442 426 // sort out the query string 443 427 text_t ttquerystring = queryparams.querystring; 444 text_t ttquotedquery;445 // extractquoted (ttquerystring, ttquotedquery);446 428 filterquery (ttquerystring); 447 448 // turn the strings into c strings for mg449 if (quotedquery != NULL) // quotedquery is a global450 {451 delete quotedquery;452 quotedquery = NULL;453 }454 455 // quotedquery will be deleted on the next call to this function456 quotedquery = to_utf8(ttquotedquery).getcstr ();457 429 char *querystring = to_utf8(ttquerystring).getcstr(); 458 430 … … 466 438 void mgsearchclass::getresults (const queryparamclass &queryparams, 467 439 queryresultsclass &queryresults) { 468 if (quotedquery[0] == '\0') { 469 // don't need the text 470 mgq_results(result_docnums, 0, MAXNUMDOCS, 471 ourquerycallback, (void *)(&queryresults)); 472 } else { 473 // we need the text for this one 474 mgq_results(result_docs, 0, MAXNUMDOCS, 475 ourquerycallback, (void *)(&queryresults)); 476 } 440 441 mgq_results(result_docnums, 0, MAXNUMDOCS, 442 ourquerycallback, (void *)(&queryresults)); 477 443 478 444 // get the term frequencies … … 501 467 } 502 468 } 503 504 505 void mgsearchclass::extractquoted (text_t &ttquerystring, text_t &ttquotedquery)506 {507 ttquotedquery.clear();508 509 text_t::iterator ithere = ttquerystring.begin ();510 text_t::iterator itend = ttquerystring.end ();511 512 bool inquote = false;513 514 while (ithere != itend)515 {516 if ((*ithere) == '\"')517 {518 if (!inquote) ttquotedquery.clear ();519 inquote = !inquote;520 *ithere = ' '; // delete the quote521 }522 else if (inquote)523 {524 ttquotedquery.push_back(*ithere);525 *ithere = ' ';526 }527 528 ithere++;529 }530 }531 532 469 533 470 void mgsearchclass::filterquery (text_t &ttquerystring) { -
trunk/gsdl/src/colservr/mgsearch.h
r350 r393 80 80 void getresults (const queryparamclass &queryparams, queryresultsclass &queryresults); 81 81 82 virtual void extractquoted (text_t &ttquerystring, text_t &ttquotedquery);83 82 virtual void filterquery (text_t &ttquerystring); 84 83 };
Note:
See TracChangeset
for help on using the changeset viewer.