Changeset 8029 for trunk/gsdl/src/recpt/querytools.cpp
- Timestamp:
- 2004-08-23T23:24:20+12:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.