Changeset 8357


Ignore:
Timestamp:
2004-10-18T12:30:06+13:00 (20 years ago)
Author:
kjdon
Message:

added a partial fix to plain searching with mgg - if you are searching in a field, it used to put [ ]:TI around the whole query string. now if you are simple 'and' searching, then it does this, otherwise it individually tags words, like [q1]:TI [q2]:TI.

Location:
trunk/gsdl/src/recpt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/queryaction.cpp

    r8029 r8357  
    13121312  get_formatted_query_string(formattedstring, segment, args, disp, logout);
    13131313
    1314 
    13151314  if (!formattedstring.empty()) { // do the query
    13161315    // note! formattedstring is in unicode! mg and mgpp must convert!
     
    13971396    // remove & | ! for simple search,do segmentation if necessary
    13981397    format_querystring (formattedstring, args.getintarg("b"), segment);
    1399     if (args["ct"]=="1") { // mgpp - we need to add in the field info
    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"]);
     1398    if (args["ct"]!=0) { // mgpp and lucene - need to add in tag info if appropriate
     1399      format_field_info(formattedstring, args);
    14041400    }
    14051401
     
    14081404          args.getintarg("ct"));
    14091405    args["q"] = formattedstring;
     1406   
    14101407  }
    14111408  else if (args["qt"]=="1" || args["qto"]=="2"){ // form search
  • trunk/gsdl/src/recpt/querytools.cpp

    r8029 r8357  
    608608
    609609
    610 void mgpp_format_field_info(text_t & querystring, const text_t &tag) {
    611 
     610void add_field_info(text_t &querystring, const text_t &tag, int type) {
     611
     612  if (type == 1) { //mgpp
     613    querystring = "["+querystring+"]:"+tag;
     614  } else if (type == 2) { // lucene
     615    querystring = tag+":("+querystring+")";
     616  }
     617   
     618}
     619
     620
     621void format_field_info(text_t &querystring, cgiargsclass &args) {
     622 
     623  text_t tag = args["fqf"];
    612624  if (tag == "ZZ" || tag == "") {
    613625    return; // do nothing
    614626  }
    615 
    616   querystring = "["+querystring+"]:"+tag;
    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 }
     627 
     628  int argct = args.getintarg("ct");
     629  int argt = args.getintarg("t");// t=0 -and, t=1 - or
     630  int argb = args.getintarg("b"); // b=0 simple, b=1 advanced
     631
     632  if (argb==0 && argt==0) {
     633    // simple 'and' search - just put tag info round whole query string
     634    add_field_info(querystring, tag, argct);
     635    return;
     636  }
     637 
     638  // we need to individually tag words
     639  text_t outtext;
     640  text_t word;
     641  //unsigned short c;                                                           
     642  text_t::const_iterator here = querystring.begin();
     643  text_t::const_iterator end = querystring.end();
     644
     645  while (here !=end) {
     646
     647    if (is_unicode_letdig(*here)|| *here == '#' || *here == '/' ) {
     648      // include term modifiers in a word just in case
     649      // not word boundary
     650      word.push_back(*here);
     651      here++;   
     652    }
     653    else {
     654      // found word boundary   
     655      if (!word.empty() ) {
     656    add_field_info(word, tag, argct);
     657    outtext += word;
     658    word.clear();
     659      }
     660      // everything else, we add into the query string
     661      outtext.push_back(*here);
     662      here++;
     663    }
     664  }
     665   
     666  // get last word
     667  if (!word.empty()) {
     668    add_field_info(word, tag, argct);
     669    outtext += word;
     670  }
     671 
     672  querystring =  outtext;
     673}
     674
  • trunk/gsdl/src/recpt/querytools.h

    r8029 r8357  
    6868text_t addstemcase(const text_t &terms, const text_t &stem, const text_t &fold);
    6969text_t formatelem(text_t &text);
    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);
    72 
     70void format_field_info(text_t &querystring, cgiargsclass &args);
    7371#endif
Note: See TracChangeset for help on using the changeset viewer.