Changeset 403 for trunk/gsdl/src/recpt/queryaction.cpp
- Timestamp:
- 1999-07-19T12:16:59+12:00 (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/queryaction.cpp
r400 r403 12 12 /* 13 13 $Log$ 14 Revision 1.16 1999/07/19 00:16:58 sjboddie 15 no longer display documents that don't match all phrases in query string 16 14 17 Revision 1.15 1999/07/16 08:33:36 rjmcnab 15 18 Changed the logic for getting the results string slightly … … 77 80 78 81 queryaction::queryaction () { 82 83 num_phrases = 0; 84 79 85 // this action uses cgi variable "a" 80 86 cgiarginfo arg_ainfo; … … 294 300 recptproto */*collectproto*/, ostream &/*logout*/) { 295 301 296 // define_internal_macros doesn't sets the following macros.302 // define_internal_macros sets the following macros: 297 303 298 304 // _quotedquery_ the part of the query string that was quoted for post-processing … … 315 321 316 322 317 318 323 // get the quoted bits of the query string and set _quotedquery_ 319 text_t &arg_q = args["q"]; 320 if (!arg_q.empty()) { 321 322 text_t::const_iterator end = arg_q.end(); 323 text_t::const_iterator here = findchar (arg_q.begin(), end, '\"'); 324 if (here != end) { 325 text_t quotedquery, tmptext; 326 bool first = true; 327 bool foundquote = false; 328 while (here != end) { 329 if (*here == '\"') { 330 if (foundquote) { 331 if (!tmptext.empty()) { 332 if (!first) quotedquery += " and "; 333 else first = false; 334 quotedquery += "\"" + tmptext + "\""; 335 tmptext.clear(); 336 } 337 foundquote = false; 338 } else foundquote = true; 339 } else { 340 if (foundquote) tmptext.push_back (*here); 341 } 342 here ++; 343 } 344 disp.setmacro ("quotedquery", "query", quotedquery); 345 } 346 } 324 text_tarray phrases; 325 get_phrases (args["q"], phrases); 326 text_tarray::const_iterator phere = phrases.begin(); 327 text_tarray::const_iterator pend = phrases.end(); 328 bool first = true; 329 text_t quotedquery; 330 while (phere != pend) { 331 if (!first) 332 if ((phere +1) == pend) quotedquery += " and "; 333 else quotedquery += ", "; 334 335 quotedquery += "\"" + *phere + "\""; 336 first = false; 337 phere ++; 338 } 339 if (args.getintarg("s")) quotedquery += "_textstemon_"; 340 disp.setmacro ("quotedquery", "query", quotedquery); 341 342 // we'll also set num_phrases here so we don't have to parse the 343 // querystring again later (we need to know this before outputting 344 // results so we don't include results for documents not containing 345 // all requested phrases). 346 num_phrases = phrases.size(); 347 347 348 } 348 349 … … 470 471 471 472 while (this_doc != end_doc) { 473 // don't include docs that didn't match phrases (if there were any) 474 // those that did match will have been sorted to the top 475 if ((*this_doc).num_phrase_match < num_phrases) break; 472 476 textout << outconvert << disp << "<tr>\n" 473 477 474 478 // << "<td valign=top nowrap>r: " << (*this_doc).ranking 475 479 // << " t: " << (*this_doc).num_terms_matched << " p: " … … 478 482 << get_formatted_string (*this_doc, formatlistptr) << "\n" 479 483 << "</tr>\n"; 484 480 485 this_doc ++; 481 486 } … … 515 520 int maxdocs = args.getintarg("m"); 516 521 int numdocs = response.numDocs; 517 if (response.isApprox == MoreThan && numdocs > maxdocs) numdocs = maxdocs; 518 519 if (response.isApprox == Approximate) resline = "_textapprox_"; 520 else if (response.isApprox == MoreThan) resline = "_textmorethan_"; 522 isapprox isApprox = response.isApprox; 523 524 // if there were phrases (post-processing) we're not going to include 525 // those documents that didn't match 526 if (num_phrases > 0) { 527 numdocs = 0; 528 isApprox = Exact; 529 ResultDocInfo_tarray::const_iterator this_doc = response.docInfo.begin(); 530 ResultDocInfo_tarray::const_iterator end_doc = response.docInfo.end(); 531 while (this_doc != end_doc) { 532 if ((*this_doc).num_phrase_match == num_phrases) numdocs ++; 533 else break; // we can bail here as matching docs are sorted to top 534 this_doc++; 535 } 536 } 537 538 if (isApprox == MoreThan && numdocs > maxdocs) numdocs = maxdocs; 539 540 if (isApprox == Approximate) resline = "_textapprox_"; 541 else if (isApprox == MoreThan) resline = "_textmorethan_"; 521 542 522 543 if (numdocs == 0) resline = "_textnodocs_";
Note:
See TracChangeset
for help on using the changeset viewer.