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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.