Changeset 11987
- Timestamp:
- 2006-06-30T16:05:50+12:00 (18 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/querytools.cpp
r11765 r11987 28 28 #include "unitool.h" // for is_unicode_letdig 29 29 30 void set_query_type_args(ColInfoResponse_t *cinfo, cgiargsclass &args) { 31 32 if (args["ct"].empty()) { 33 text_t build_type = cinfo->buildType; 34 if (build_type == "mgpp") { 35 args["ct"] = "1"; 36 } else if (build_type == "lucene") { 37 args["ct"] = "2"; 38 } else { 39 args["ct"] = "0"; 40 } 41 } 42 text_t arg_ct = args["ct"]; 43 if (arg_ct == "0") { 44 // mg 45 args["qt"] = "0"; 46 args["qto"] = "0"; 47 return; 48 } 49 50 if (!args["qt"].empty() && !args["qto"].empty()) { 51 return; 52 } 53 54 text_tmap::iterator check = cinfo->format.find("SearchTypes"); 55 text_t search_types = "plain,form"; 56 if(check != cinfo->format.end()){ 57 search_types = (*check).second; 58 if (search_types.empty()) { 59 search_types = "plain,form"; 60 } 61 } 62 63 if (args["qto"].empty()) { 64 unsigned int type = 0; 65 if (findword(search_types.begin(), search_types.end(), "form") != search_types.end()) { 66 type |= 2; 67 } 68 if (findword(search_types.begin(), search_types.end(), "plain") != search_types.end()) { 69 type |= 1; 70 } 71 args.setintarg("qto", type); 72 } 73 74 if (args["qt"].empty()) { 75 bool form_default = false; 76 int arg_qto = args.getintarg("qto"); 77 if (arg_qto == 2 || (arg_qto == 3 && starts_with(search_types, "form"))) { 78 args["qt"] = "1"; 79 } else { 80 args["qt"] = "0"; 81 } 82 } 83 } 84 30 85 // request.filterResultOptions and request.fields (if required) should 31 86 // be set from the calling code … … 157 212 // option.value = endresults; 158 213 // request.filterOptions.push_back (option); 214 } 215 216 bool is_special_character(int indexer_type, unsigned short character) { 217 // mgpp 218 if (indexer_type == 1) { 219 return (character == '#' || character == '/' || character == '*'); 220 } 221 // lucene 222 else if (indexer_type ==2) { 223 return (character == '?' || character == '*' || character == '~' || 224 character == '^'); 225 } 226 return false; 159 227 } 160 228 … … 386 454 } 387 455 } 388 text_t term = addstemcase(values[i], stems[i], folds[i] );456 text_t term = addstemcase(values[i], stems[i], folds[i], ct); 389 457 mgpp_addqueryelem(querystring, fields[i], term, combine); 390 458 } … … 393 461 } 394 462 395 text_t addstemcase(const text_t &terms, const text_t &stem, const text_t &fold) { 463 text_t addstemcase(const text_t &terms, const text_t &stem, const text_t &fold, 464 const int indexer_type) { 396 465 397 466 text_t outtext; … … 403 472 while (here !=end) { 404 473 405 if (is_unicode_letdig(*here) ) {474 if (is_unicode_letdig(*here) || is_special_character(indexer_type, *here)) { 406 475 // not word boundary 407 476 word.push_back(*here); … … 598 667 } 599 668 600 bool is_special_character(int indexer_type, unsigned short character) {601 // mgpp602 if (indexer_type == 1) {603 return (character == '#' || character == '/' || character == '*');604 }605 // lucene606 else if (indexer_type ==2) {607 return (character == '?' || character == '*' || character == '~' ||608 character == '^');609 }610 return false;611 }612 669 613 670 void format_field_info_lucene(text_t &querystring, cgiargsclass &args) { … … 691 748 692 749 void format_field_info_mgpp(text_t &querystring, cgiargsclass &args) { 693 694 750 text_t tag = args["fqf"]; 695 751 if (tag == "ZZ") tag = ""; // ZZ is a special tag meaning no tag (all fields) -
trunk/gsdl/src/recpt/querytools.h
r11004 r11987 30 30 #include "cgiargs.h" 31 31 #include "recptproto.h" 32 33 void set_query_type_args(ColInfoResponse_t *cinfo, cgiargsclass &args); 32 34 33 35 void set_queryfilter_options (FilterRequest_t &request, const text_t &querystring, … … 64 66 const text_t &terms, const text_t &stem, const text_t &fold, 65 67 const text_t& combine, const text_t& word_combine); 66 text_t addstemcase(const text_t &terms, const text_t &stem, const text_t &fold); 68 text_t addstemcase(const text_t &terms, const text_t &stem, const text_t &fold, 69 const int indexer_type); 67 70 text_t formatelem(text_t &text); 68 71 void format_field_info(text_t &querystring, cgiargsclass &args);
Note:
See TracChangeset
for help on using the changeset viewer.