Changeset 766 for trunk/gsdl


Ignore:
Timestamp:
1999-11-02T11:06:06+13:00 (25 years ago)
Author:
sjboddie
Message:

Added filter option to remove documents not matching a phrase match.
This used to be done in the receptionist.

Location:
trunk/gsdl/src/colservr
Files:
2 edited

Legend:

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

    r722 r766  
    2828/*
    2929   $Log$
     30   Revision 1.20  1999/11/01 22:06:06  sjboddie
     31   Added filter option to remove documents not matching a phrase match.
     32   This used to be done in the receptionist.
     33
    3034   Revision 1.19  1999/10/19 03:23:40  davidb
    3135   Collection building support through web pages
     
    243247    get_phrase_terms (queryparams.querystring, queryresults.orgterms, phrases);
    244248
    245     if (phrases.size() > 0) {
     249    num_phrases = phrases.size();
     250    if (num_phrases > 0) {
    246251
    247252      // get the long version of the index
     
    276281void queryfilterclass::parse_query_params (const FilterRequest_t &request,
    277282                       vector<queryparamclass> &query_params,
    278                        int &startresults,
    279                        int &endresults,
    280                        ostream &logout) {
     283                       int &startresults, int &endresults,
     284                       text_t &phrasematch, ostream &logout) {
    281285  outconvertclass text_t2ascii;
    282286
     
    285289  startresults = filterOptions["StartResults"].defaultValue.getint();
    286290  endresults = filterOptions["EndResults"].defaultValue.getint();
     291  phrasematch = filterOptions["PhraseMatch"].defaultValue;
    287292
    288293  // set defaults for query parameters
     
    352357    } else if ((*options_here).name == "Maxdocs") {
    353358      query.maxdocs = (*options_here).value.getint();
     359    } else if ((*options_here).name == "PhraseMatch") {
     360      phrasematch = (*options_here).value;
    354361    } else {
    355362      logout << text_t2ascii
     
    464471  gdbmptr = NULL;
    465472  mgsearchptr = NULL;
     473  num_phrases = 0;
    466474
    467475  FilterOption_t filtopt;
     
    576584  filtopt.validValues.push_back("1000");
    577585  filterOptions["Maxdocs"] = filtopt;
     586
     587  // -- onePerQuery  PhraseMatch  enumerated
     588  filtopt.clear();
     589  filtopt.name = "PhraseMatch";
     590  filtopt.type = FilterOption_t::enumeratedt;
     591  filtopt.repeatable = FilterOption_t::onePerQuery;
     592  filtopt.defaultValue = "some_phrases";
     593  filtopt.validValues.push_back ("all_phrases");
     594  filtopt.validValues.push_back ("some_phrases");
     595  filtopt.validValues.push_back ("all_docs");
     596  filterOptions["PhraseMatch"] = filtopt;
    578597}
    579598
     
    678697  int startresults = filterOptions["StartResults"].defaultValue.getint();
    679698  int endresults = filterOptions["EndResults"].defaultValue.getint();
     699  text_t phrasematch = filterOptions["PhraseMatch"].defaultValue;
     700
    680701  vector<queryparamclass> queryfilterparams;
    681   parse_query_params (request, queryfilterparams, startresults, endresults, logout); 
     702  parse_query_params (request, queryfilterparams, startresults,
     703              endresults, phrasematch, logout); 
    682704 
    683705  // do query
     
    710732    docresultmap::iterator docset_here = queryresults.docs.docset.find (*docorder_here);
    711733   
     734    // documents containing matching phrases will be sorted to the top so
     735    // we can break out once we're past those that match the PhraseMatch
     736    // option -- "all_phrases" = return only those documents containing all
     737    //                       phrases in query string
     738    //           "some_phrases" = return only those documents containing
     739    //                            at least 1 of the phrases in the document
     740    //           "all_docs" = return all documents regardless
     741    if (num_phrases > 0) {
     742      if ((phrasematch == "all_phrases") && ((*docset_here).second.num_phrase_match < num_phrases))
     743        break;
     744      if ((phrasematch == "some_phrases") && ((*docset_here).second.num_phrase_match < 1))
     745        break;
     746    }
     747
    712748    // see if there is a result for this number,
    713749    // if it is in the request set (or the request set is empty)
  • trunk/gsdl/src/colservr/queryfilter.h

    r534 r766  
    6666 
    6767  mgsearchclass *mgsearchptr;
    68 
     68 
     69  int num_phrases;
    6970
    7071  void get_phrase_terms (const text_t &querystring,
     
    7980  void parse_query_params (const FilterRequest_t &request,
    8081               vector<queryparamclass> &query_params,
    81                int &startresults,
    82                int &endresults,
    83                ostream &logout);
     82               int &startresults, int &endresults,
     83               text_t &phrasematch, ostream &logout);
    8484
    8585  // do query that might involve multiple sub queries
Note: See TracChangeset for help on using the changeset viewer.