Ignore:
Timestamp:
2013-03-12T14:37:44+13:00 (11 years ago)
Author:
kjdon
Message:

adding reverse sort/sort order in for lucene search results sorting. reorganising code to avoid duplication, added fieldedqueryfilter in the chain of inheritance

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/colservr/mgppqueryfilter.cpp

    r20727 r27064  
    11/**********************************************************************
    22 *
    3  * queryfilter.cpp --
     3 * mgppqueryfilter.cpp --
    44 * Copyright (C) 1999  The New Zealand Digital Library Project
    55 *
     
    2828#include "mgppsearch.h"
    2929
    30 /////////////////////////////////
    31 // functions for queryfilterclass
    32 /////////////////////////////////
    33 
    34 
    3530mgppqueryfilterclass::mgppqueryfilterclass ()
    36   : queryfilterclass() {
    37 
    38  
    39   FilterOption_t filtopt;
    40  
    41   // -- onePerTerm  Level          enumerated
    42   // likely to be Doc, Sec, Para, but we dont assume anything now
    43   filtopt.clear();
    44   filtopt.name = "Level";
    45   filtopt.type = FilterOption_t::enumeratedt;
    46   filtopt.repeatable = FilterOption_t::onePerTerm;
    47   filtopt.defaultValue = "";
    48   filterOptions["Level"] = filtopt;
    49 
    50   // --  IndexField, enumerated, used to list available fields
    51   filtopt.clear();
    52   filtopt.name = "IndexField";
    53   filtopt.type = FilterOption_t::enumeratedt;
    54   filtopt.repeatable = FilterOption_t::onePerTerm;
    55   filtopt.defaultValue = "";
    56   filterOptions["IndexField"] = filtopt;
     31  : fieldedqueryfilterclass() {
    5732
    5833}
     
    6237
    6338
    64 //whether a query is a full text browse
    65 bool mgppqueryfilterclass::full_text_browse (int filterRequestOptions) {
    66   return (filterRequestOptions & FRfullTextBrowse);
    67 }
    6839
    6940void mgppqueryfilterclass::configure (const text_t &key, const text_tarray &cfgline) {
    70   queryfilterclass::configure(key, cfgline);
    71 
    72   if (key == "indexfieldmap") {
    73     indexfieldmap.importmap (cfgline);
    74     text_tarray options;
    75     indexfieldmap.gettoarray (options);
    76     filterOptions["IndexField"].validValues = options;
    77    
    78   } else if (key == "levelmap") {
    79     levelmap.importmap (cfgline);
    80   } else if (key == "indexlevels") {
    81     filterOptions["Level"].validValues.erase(filterOptions["Level"].validValues.begin(), filterOptions["Level"].validValues.end());
    82     text_tarray::const_iterator here = cfgline.begin();
    83     text_tarray::const_iterator end = cfgline.end();
    84     while (here != end) {
    85       if (!(*here).empty()) {
    86     filterOptions["Level"].validValues.push_back(*here);
    87       }
    88       ++here;
    89     }
    90   } else if (key == "textlevel") {
    91       ((mgppsearchclass *)textsearchptr)->set_text_level(cfgline[0]);
     41  fieldedqueryfilterclass::configure(key, cfgline);
     42
     43  if (key == "textlevel") {
     44    ((mgppsearchclass *)textsearchptr)->set_text_level(cfgline[0]);
    9245  } else if (key == "indexstem") {
    9346    ((mgppsearchclass *)textsearchptr)->set_indexstem (cfgline[0]);
    94   } else if (key == "defaultindex") { // used for fields in mgpp
    95     indexfieldmap.from2to (cfgline[0], filterOptions["IndexField"].defaultValue);
    96   } else if (key == "defaultlevel") {
    97     levelmap.from2to (cfgline[0], filterOptions["Level"].defaultValue);
    98   }
    99  
    100 }
    101 
    102 bool mgppqueryfilterclass::init (ostream &logout) {
    103  
    104   if (!queryfilterclass::init(logout)) {
    105     return false;
    106   }
    107  
    108   if (filterOptions["IndexField"].defaultValue.empty()) {
    109     // use first index in map as default if no default is set explicitly
    110     text_tarray fromarray;
    111     indexfieldmap.getfromarray(fromarray);
    112     if (fromarray.size()) {
    113       filterOptions["IndexField"].defaultValue = fromarray[0];
    114     }
    115   }
    116   if (filterOptions["Levels"].defaultValue.empty()) {
    117     // use first level as default if no default is set explicitly
    118     if (!filterOptions["Level"].validValues[0].empty())
    119       filterOptions["Levels"].defaultValue = filterOptions["Level"].validValues[0];
    120   }
    121 
    122   return true;
     47  }
    12348}
    12449
     
    16388  // get the query parameters
    16489  int startresults, endresults;
    165   text_t phrasematch; // not used here any more
    16690  vector<queryparamclass> queryfilterparams;
    16791  parse_query_params (request, queryfilterparams, startresults,
    168               endresults, phrasematch, logout); 
     92              endresults, logout); 
    16993 
    17094   
     
    261185  // get the query parameters
    262186  int startresults, endresults;
    263   text_t phrasematch; // not used here any more, just have it so can use
    264                       // parse_query_params function
    265  
    266187  vector<queryparamclass> queryfilterparams;
    267188  parse_query_params (request, queryfilterparams, startresults,
    268               endresults, phrasematch, logout); 
     189              endresults, logout); 
    269190
    270191    vector<queryparamclass>::const_iterator query_here = queryfilterparams.begin();
Note: See TracChangeset for help on using the changeset viewer.