Changeset 12276


Ignore:
Timestamp:
2006-07-24T02:57:51+12:00 (18 years ago)
Author:
sjboddie
Message:

Added "Sort Field" (sf) argument that can be passed through to a lucene
collection to sort search results by a metadata field.

Location:
trunk/gsdl/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/colservr/lucenesearch.cpp

    r12246 r12276  
    123123    if (*here == '"') escaped_utf8querystring.push_back('\\');
    124124    escaped_utf8querystring.push_back(*here);
    125     here++;
     125    ++here;
    126126  }
    127127  cerr << "**** escaped query string = " << escaped_utf8querystring << endl;
     
    130130  text_t cmd = "\"" + filename_cat(gsdlhome, "bin", "script", "lucene_query.pl") + "\"";
    131131  cmd += (text_t)" \""+indexname + (text_t)"\" \"" + escaped_utf8querystring + (text_t)"\"";
     132  if (!queryparams.sortfield.empty()) {
     133    cmd += " \"" + queryparams.sortfield + "\"";
     134  }
    132135  cerr << "Lucene command: " << cmd << endl;
    133136 
  • trunk/gsdl/src/colservr/queryfilter.cpp

    r9937 r12276  
    9090  query.maxdocs = filterOptions["Maxdocs"].defaultValue.getint();
    9191  query.level = filterOptions["Level"].defaultValue;
     92  query.sortfield = filterOptions["SortField"].defaultValue;
    9293  OptionValue_tarray::const_iterator options_here = request.filterOptions.begin();
    9394  OptionValue_tarray::const_iterator options_end = request.filterOptions.end();
     
    115116      query.stemming = (filterOptions["Stem"].defaultValue == "true");
    116117      query.level = filterOptions["Level"].defaultValue;
     118      query.sortfield = filterOptions["SortField"].defaultValue;
    117119      // "all", needed when combining queries where the document results are needed
    118120      if (need_matching_docs (request.filterResultOptions)) query.maxdocs = -1;
     
    146148    } else if ((*options_here).name == "Level") {
    147149      query.level = (*options_here).value;
     150    } else if ((*options_here).name == "SortField") {
     151      query.sortfield = (*options_here).value;
    148152    } else {
    149153      logout << text_t2ascii
  • trunk/gsdl/src/colservr/queryinfo.cpp

    r9620 r12276  
    4747  maxdocs = -1;    // all
    4848  maxnumeric = 4;  // must default to the same value as mg_passes
     49  sortfield.clear();
    4950}
    5051
     
    6465  maxdocs = q.maxdocs;
    6566  maxnumeric = q.maxnumeric;
     67  sortfield = q.sortfield;
    6668
    6769  return *this;
     
    8284      (x.stemming == y.stemming) &&
    8385      (x.maxdocs == y.maxdocs) &&
    84       (x.maxnumeric == y.maxnumeric));
     86      (x.maxnumeric == y.maxnumeric) &&
     87          (x.sortfield == y.sortfield));
    8588}
    8689
     
    107110  outs << " maxdocs = \"" << q.maxdocs << "\"\n";
    108111  outs << " maxnumeric = \"" << q.maxnumeric << "\"\n";
     112  outs << " sortfield = \"" << q.sortfield << "\"\n";
    109113  outs << "\n";
    110114
  • trunk/gsdl/src/colservr/queryinfo.h

    r4217 r12276  
    6666  int maxdocs;
    6767  int maxnumeric;
     68  text_t sortfield; // Field to use for sorting result set (currently used by lucene)
    6869
    6970  queryparamclass ();
  • trunk/gsdl/src/recpt/queryaction.cpp

    r12161 r12276  
    429429  argsinfo.addarginfo (NULL, arg_ainfo);
    430430
     431  // "sf" - Sort field. Set to field to be used for sorting search reult
     432  // set (only implemented for lucene collections at present).
     433  arg_ainfo.shortname = "sf";
     434  arg_ainfo.longname = "sort field";
     435  arg_ainfo.multiplechar = true;
     436  arg_ainfo.defaultstatus = cgiarginfo::weak;
     437  arg_ainfo.argdefault = g_EmptyText;
     438  arg_ainfo.savedarginfo = cgiarginfo::must;
     439  argsinfo.addarginfo (NULL, arg_ainfo);
    431440}
    432441
  • trunk/gsdl/src/recpt/querytools.cpp

    r11987 r12276  
    138138    option.name = "Level";
    139139    option.value = args["g"];
     140    request.filterOptions.push_back (option);
     141  }
     142
     143  if (!args["sf"].empty()) { // sort field for lucene
     144    option.name = "SortField";
     145    option.value = args["sf"];
    140146    request.filterOptions.push_back (option);
    141147  }
Note: See TracChangeset for help on using the changeset viewer.