Changeset 1900
- Timestamp:
- 2001-02-02T14:33:01+13:00 (23 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/z3950proto.cpp
r1738 r1900 351 351 // go through options 352 352 text_t opt_term; // the term(s) that the user entered 353 int opt_querytype=0; // 1=>ranked (or), 2=>boolean (and) 353 354 text_t opt_fields; // which fields to search on 354 355 int opt_start=1, opt_end=20; // default values … … 357 358 OptionValue_tarray::iterator ov_end=request.filterOptions.end(); 358 359 while (ov_here != ov_end) { 359 // cerr << "OV pair: `" << ov_here->name.getcstr() << "'=`" 360 // << ov_here->value.getcstr() << "'\n"; 361 if (ov_here->name=="Term") 362 { 363 opt_term=ov_here->value; 364 } else if (ov_here->name=="Index") 365 { 366 opt_fields=ov_here->value; 367 } else if (ov_here->name=="StartResults") 368 { 369 opt_start=ov_here->value.getint(); 370 } else if (ov_here->name=="EndResults") 371 { 372 opt_end=ov_here->value.getint(); 373 } else if (ov_here->name=="Maxdocs") 374 { 375 maxdocs=ov_here->value.getint(); 376 } 360 if (ov_here->name=="Term") { 361 opt_term=ov_here->value; 362 } else if (ov_here->name=="QueryType") { 363 if (ov_here->value=="ranked") opt_querytype=1; 364 else if (ov_here->value=="boolean") opt_querytype=2; 365 else { /* error - shouldn't happen */ 366 /* currently unhandled */ 367 } 368 } else if (ov_here->name=="Index") { 369 opt_fields=ov_here->value; 370 } else if (ov_here->name=="StartResults") { 371 opt_start=ov_here->value.getint(); 372 } else if (ov_here->name=="EndResults") { 373 opt_end=ov_here->value.getint(); 374 } else if (ov_here->name=="Maxdocs") { 375 maxdocs=ov_here->value.getint(); 376 } 377 377 ov_here++; 378 378 } 379 379 err=noError; 380 380 text_tarray *titles=(*zserver)->getrecordTitles(opt_term, 381 opt_querytype, 381 382 opt_fields, 382 383 opt_start, // first to get … … 422 423 } // end of if (... & FRtermFreq) 423 424 424 } // end of if (... & FROID)425 } // end of if (... == "QueryFilter") 425 426 else { 426 427 // this wasn't a query action … … 443 444 response.docInfo.push_back(*docInfo); 444 445 } 445 } 446 } // end of not a query action 447 448 446 449 447 450 // Fill in metadata for each response.docInfo (if wanted) … … 450 453 // should check err returned here.... 451 454 452 // get the Query out of the filterOptions.453 text_t query="";454 text_t field="";455 OptionValue_tarray::iterator opt_here=request.filterOptions.begin();456 OptionValue_tarray::iterator opt_end=request.filterOptions.end();457 while (opt_here!=opt_end) {458 if (opt_here->name=="Query") {459 query=opt_here->value;460 if (field!="") break; // break from loop if we've got both461 } else if (opt_here->name=="Index") {462 field=opt_here->value;463 if (query!="") break; // break from loop if we've got both464 }465 opt_here++;466 }467 468 455 if (!request.fields.empty()) { 456 // currently, this is only true for NullFilter when getting the "Title" 457 // for a documentaction. 458 469 459 // loop on each document being returned 470 460 ResultDocInfo_tarray::iterator docs_here=response.docInfo.begin(); 471 461 ResultDocInfo_tarray::iterator docs_end=response.docInfo.end(); 472 462 while (docs_here!=docs_end) { 473 474 463 // loop on all the metadata fields in request.fields (type text_tset) 475 464 text_tset::iterator fields_here=request.fields.begin(); … … 489 478 i=request.docSet[0].getint(); 490 479 text_t doctext="unneeded"; 491 (*zserver)->getfullrecord(query, field, i, doctitle, doctext, err); 480 /* following variables aren't used, as our query result has been 481 cached in z3950server.cpp (but really we shouldn't know that 482 here...) But for the NullFilter, we don't get given these 483 again in the request, so for now we'll take advantage of this.*/ 484 485 int querytype=0; text_t field=""; 486 487 // get the Query out of the filterOptions. (we need get the Title) 488 text_t query=""; 489 OptionValue_tarray::iterator opthere=request.filterOptions.begin(); 490 OptionValue_tarray::iterator opt_end=request.filterOptions.end(); 491 while (opthere!=opt_end) { 492 if (opthere->name=="Query") { 493 query=opthere->value; 494 break; 495 } 496 opthere++; 497 } 498 (*zserver)->getfullrecord(query, querytype, field, i, doctitle, doctext, err); 492 499 // check err value! 493 500 docs_here->metadata["Title"].values.push_back(doctitle); 494 501 } else { 495 502 docs_here->metadata[*fields_here].values.push_back(""); 496 /////// cerr << " (not found)";497 503 } 498 504 fields_here++; … … 501 507 } // end of outer while loop 502 508 } // end of if (!request.fields.empty()) 503 509 504 510 else { // request.fields empty: return all metadata for about page or query 505 511 // we'll only put it in the first docInfo. … … 571 577 text_t query; // this should not be needed, as we have already connected to 572 578 // get the title.... 573 text_t field; // ditto... 574 (*zserver)->getfullrecord(query,field,request.OID.getint(), 579 int querytype; //ditto... 580 text_t field; // ditto... 581 (*zserver)->getfullrecord(query,querytype,field,request.OID.getint(), 575 582 title,doctext,err); 576 583 // check return value of above? (false=>not connected) -
trunk/gsdl/src/recpt/z3950server.cpp
r1738 r1900 107 107 108 108 void z3950_server::parseQuery(const text_t &query, 109 const int querytype, 109 110 const text_t &fields, 110 111 text_t &parsed_query) { … … 127 128 bool inword=false; 128 129 int num_terms=0; 130 129 131 130 132 for (int i=0;i<strlength;i++) { … … 161 163 parsed_query+="1016 "; 162 164 165 // querytype=1 => ranked/or, =2 => boolean/and 163 166 // append "@and" for each term after the first 164 for (int i=1;i<num_terms;i++) 165 parsed_query+="@and "; 166 // append the actual query 167 parsed_query+=ptr; 168 167 { 168 char and_str[]="@and "; 169 char or_str[]="@or "; 170 char *q_type; 171 if (querytype==1) q_type=or_str; else q_type=and_str; 172 for (int i=1;i<num_terms;i++) 173 parsed_query+=q_type; 174 // append the actual query 175 parsed_query+=ptr; 176 } 169 177 delete ptr; 170 178 } 171 179 172 180 text_tarray *z3950_server::getrecordTitles(const text_t &query, 181 const int querytype, 173 182 const text_t &fields, 174 183 int first, int count, … … 210 219 211 220 text_t expanded_query=""; 212 parseQuery(query, fields,expanded_query);221 parseQuery(query,querytype,fields,expanded_query); 213 222 214 223 char* query_str=expanded_query.getcstr(); … … 253 262 } 254 263 255 bool z3950_server::getfullrecord(const text_t &query, const text_t &fields, 264 bool z3950_server::getfullrecord(const text_t &query, 265 const int querytype, 266 const text_t &fields, 256 267 const int ID, 257 268 text_t &rettitle, … … 279 290 280 291 text_t expanded_query=""; 281 parseQuery(query, fields,expanded_query);292 parseQuery(query,querytype,fields,expanded_query); 282 293 283 294 char* query_str=expanded_query.getcstr(); -
trunk/gsdl/src/recpt/z3950server.h
r1617 r1900 58 58 text_t &getzAbout(); // gets any name, id, MOTD, etc from server. 59 59 text_tarray *getrecordTitles(const text_t &query, 60 const int querytype, 60 61 const text_t &fields, 61 62 const int first, const int count, … … 63 64 /* only get one record at a time? (Eventually we could buffer them, but 64 65 for now... */ 65 bool getfullrecord(const text_t &query, const text_t &fields, 66 bool getfullrecord(const text_t &query, const int querytype, 67 const text_t &fields, 66 68 const int ID, text_t &rettitle, 67 69 text_t &rettext,comerror_t &err); 68 70 private: 69 void parseQuery(const text_t &query, const text_t &fields, 71 void parseQuery(const text_t &query, const int querytype, 72 const text_t &fields, 70 73 text_t &parsed_query); 71 74 };
Note:
See TracChangeset
for help on using the changeset viewer.