Changeset 8029
- Timestamp:
- 2004-08-23T23:24:20+12:00 (20 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/queryaction.cpp
r7594 r8029 63 63 argsinfo.addarginfo (NULL, arg_ainfo); 64 64 65 // "ct" - 0 = mg, 1 = mgpp 65 // "ct" - 0 = mg, 1 = mgpp, 2=lucene 66 66 arg_ainfo.shortname = "ct"; 67 67 arg_ainfo.longname = "collection type"; … … 506 506 // check ct argument 507 507 int arg_ct = args.getintarg("ct"); 508 if (arg_ct !=0 && arg_ct !=1) {508 if (arg_ct <0 && arg_ct >2) { 509 509 logout << "Warning: \"ct\" argument out of range (" << arg_ct << ")\n"; 510 510 cgiarginfo *ctinfo = argsinfo.getarginfo ("ct"); … … 708 708 if (it != end) set_option_macro ("cq2", args["cq2"], true,false, (*it).second, disp); 709 709 710 if ( args["ct"] == "1") { // mgppcollections710 if ((args["ct"] == "1") || (args["ct"] == "2")) { // mgpp/lucene collections 711 711 // _gselection_ (Level) 712 712 it = response.filterOptions.find("Level"); … … 789 789 // _advformlist_ 790 790 791 if (args["ct"]=="0" || args["qto"]=="1" || (args["qto"]=="3" && args["qt"] == "0") ) // mg, or mgpp with plain only, or mgpp with both, but set to plain791 if (args["ct"]=="0" || args["qto"]=="1" || (args["qto"]=="3" && args["qt"] == "0") ) // mg, or mgpp/lucene with plain only, or mgpp with both, but set to plain 792 792 return; // dont need these macros 793 793 794 794 // mgpp & form query only needs the macros defined 795 795 text_t form = ""; 796 796 int argfqn = args.getintarg("fqn"); … … 1398 1398 format_querystring (formattedstring, args.getintarg("b"), segment); 1399 1399 if (args["ct"]=="1") { // mgpp - we need to add in the field info 1400 format_field_info(formattedstring, args["fqf"]); 1401 } 1400 mgpp_format_field_info(formattedstring, args["fqf"]); 1401 } 1402 else if (args["ct"]=="2") { // lucene - we need to add in the field info 1403 lucene_format_field_info(formattedstring, args["fqf"]); 1404 } 1405 1402 1406 add_dates(formattedstring, args.getintarg("ds"), args.getintarg("de"), 1403 args.getintarg("dsbc"), args.getintarg("debc")); 1407 args.getintarg("dsbc"), args.getintarg("debc"), 1408 args.getintarg("ct")); 1404 1409 args["q"] = formattedstring; 1405 1410 } -
trunk/gsdl/src/recpt/querytools.cpp
r7432 r8029 198 198 199 199 void add_dates(text_t &querystring, int startdate, int enddate, 200 int startbc, int endbc )200 int startbc, int endbc, int ct) 201 201 { 202 202 if(startdate) … … 232 232 if(!enddate) 233 233 { 234 querystring.appendcstr(" ["); 235 if(startdate<0) 236 { 237 querystring.appendcstr("bc"); 238 querystring.appendint((startdate*-1)); 239 } 240 else 241 querystring.appendint(startdate); 242 querystring.appendcstr("]:CV"); 234 if (ct==1) { 235 mgpp_adddateelem(querystring,startdate); 236 } 237 else { // lucene 238 lucene_adddateelem(querystring,startdate); 239 } 243 240 } 244 241 else{ … … 247 244 while(nextdate<=enddate) 248 245 { 249 if(nextdate!=0) 250 { 251 querystring.appendcstr(" ["); 252 if(nextdate<0) 253 { 254 querystring.appendcstr("bc"); 255 querystring.appendint((nextdate*-1)); 256 } 257 else 258 querystring.appendint(nextdate); 259 querystring.appendcstr("]:CV"); 246 if(nextdate!=0) { 247 if (ct==1) { 248 mgpp_adddateelem(querystring,nextdate); 260 249 } 250 else { // lucene 251 lucene_adddateelem(querystring,nextdate); 252 } 253 } 261 254 nextdate++; 262 255 } … … 320 313 // some query form parsing functions for use with mgpp 321 314 322 void parse_reg_query_form(text_t &querystring, cgiargsclass &args) {323 315 void parse_reg_query_form(text_t &querystring, cgiargsclass &args) 316 { 324 317 querystring.clear(); 318 319 const int ct = args.getintarg("ct"); 320 int argt = args.getintarg("t");// t=0 -and, t=1 - or 321 325 322 text_t combine; 326 int argt = args.getintarg("t");// t=0 -and, t=1 - or 327 if (argt == 0) combine = "&"; 328 else combine = "|"; 323 if (ct==1) { 324 if (argt == 0) combine = "&"; 325 else combine = "|"; 326 } 327 else { // lucene 328 if (argt == 0) combine = "AND"; 329 else combine = "OR"; 330 } 329 331 330 332 text_t field = args["fqf"]; … … 338 340 splitchar(value.begin(), value.end(), ',', values); 339 341 342 340 343 for (int i=0; i< values.size(); i++) { 341 344 if (!values[i].empty()) { 342 addqueryelem(querystring, fields[i], values[i], combine); 345 if (ct == 1) { 346 mgpp_addqueryelem(querystring, fields[i], values[i], combine); 347 } 348 else { // lucene 349 lucene_addqueryelem(querystring, fields[i], values[i], combine); 350 } 343 351 } 344 352 } … … 350 358 351 359 querystring.clear(); 352 text_t combine = "&"; 360 361 const int ct = args.getintarg("ct"); 362 text_t combine; 363 if (ct==1) { 364 combine = "&"; 365 } 366 else { // lucene 367 combine = "AND"; 368 } 353 369 354 370 text_t field = args["fqf"]; … … 380 396 if (!values[i].empty()) { 381 397 if (i!=0) { 382 if (combs[i-1]=="and") combine = "&"; 383 else if (combs[i-1]=="or")combine = "|"; 384 else if (combs[i-1]=="not")combine = "!"; 398 if (ct==1) { 399 if (combs[i-1]=="and") combine = "&"; 400 else if (combs[i-1]=="or")combine = "|"; 401 else if (combs[i-1]=="not")combine = "!"; 402 } 403 else { // lucene 404 if (combs[i-1]=="and") combine = "AND"; 405 else if (combs[i-1]=="or")combine = "OR"; 406 else if (combs[i-1]=="not")combine = "NOT"; 407 } 385 408 } 386 409 text_t term = addstemcase(values[i], stems[i], folds[i]); 387 addqueryelem(querystring, fields[i], term, combine);410 mgpp_addqueryelem(querystring, fields[i], term, combine); 388 411 } 389 412 … … 446 469 447 470 448 void addqueryelem(text_t &querystring, text_t &tag, 471 void mgpp_adddateelem(text_t& querystring, const int date) 472 { 473 querystring.appendcstr(" ["); 474 if(date<0) { 475 querystring.appendcstr("bc"); 476 querystring.appendint((date*-1)); 477 } 478 else { 479 querystring.appendint(date); 480 } 481 querystring.appendcstr("]:CV"); 482 } 483 484 void lucene_adddateelem(text_t& querystring, const int date) 485 { 486 querystring.appendcstr(" CV:("); 487 if(date<0) { 488 querystring.appendcstr("bc"); 489 querystring.appendint((date*-1)); 490 } 491 else { 492 querystring.appendint(date); 493 } 494 querystring.appendcstr(")"); 495 } 496 497 498 void mgpp_addqueryelem(text_t &querystring, text_t &tag, 449 499 text_t &query, text_t &combine) { 450 500 if (!querystring.empty()) { // have to put and/or 451 querystring += " " +combine + " ";501 querystring += " " + combine + " "; 452 502 453 503 } … … 459 509 } 460 510 511 } 512 513 void lucene_addqueryelem(text_t &querystring, text_t &tag, 514 text_t &query, text_t &combine) { 515 if (!querystring.empty()) { // have to put and/or 516 querystring += " " + combine + " "; 517 518 } 519 if (tag=="ZZ" || tag=="") { // just add onto querystring 520 querystring += query; 521 } 522 else { 523 querystring += tag+":("+query+")"; 524 } 461 525 } 462 526 … … 544 608 545 609 546 void format_field_info(text_t & querystring, const text_t &tag) {610 void mgpp_format_field_info(text_t & querystring, const text_t &tag) { 547 611 548 612 if (tag == "ZZ" || tag == "") { … … 552 616 querystring = "["+querystring+"]:"+tag; 553 617 } 618 619 void lucene_format_field_info(text_t & querystring, const text_t &tag) { 620 621 if (tag == "ZZ" || tag == "") { 622 return; // do nothing 623 } 624 625 querystring = tag+":("+querystring+")"; 626 } -
trunk/gsdl/src/recpt/querytools.h
r7383 r8029 43 43 44 44 void add_dates(text_t &querystring, int startdate, int enddate, 45 int startbc, int endbc );45 int startbc, int endbc, int ct); 46 46 47 47 void get_phrases (const text_t &querystring, text_tarray &phrases); … … 56 56 void parse_adv_query_form(text_t &formattedstring, cgiargsclass &args); 57 57 58 void addqueryelem(text_t &querystring, text_t &tag, 58 void mgpp_adddateelem(text_t& querystring, const int date); 59 void lucene_adddateelem(text_t& querystring, const int date); 60 61 void mgpp_addqueryelem(text_t &querystring, text_t &tag, 62 text_t &query, text_t &combine); 63 void lucene_addqueryelem(text_t &querystring, text_t &tag, 59 64 text_t &query, text_t &combine); 60 65 void addqueryelem_ex(text_t &querystring, const text_t &tag, … … 63 68 text_t addstemcase(const text_t &terms, const text_t &stem, const text_t &fold); 64 69 text_t formatelem(text_t &text); 65 void format_field_info(text_t &querystring, const text_t &tag); 70 void mgpp_format_field_info(text_t &querystring, const text_t &tag); 71 void lucene_format_field_info(text_t &querystring, const text_t &tag); 66 72 67 73 #endif
Note:
See TracChangeset
for help on using the changeset viewer.