pike.git / lib / modules / Search.pmod / Query.pmod

version» Context lines:

pike.git/lib/modules/Search.pmod/Query.pmod:1:   // This file is part of Roxen Search   // Copyright © 2001 Roxen IS. All rights reserved.   // - // $Id: Query.pmod,v 1.21 2001/08/09 14:49:01 norlin Exp $ + // $Id: Query.pmod,v 1.22 2001/09/01 22:13:08 js Exp $      static function(string,int:string) blobfeeder(Search.Database.Base db, array words)   {    mapping state = mkmapping(words,allocate(sizeof(words)));    return lambda( string word, int foo )    {    return db->get_blob(word, state[word]++);    };   }   
pike.git/lib/modules/Search.pmod/Query.pmod:23:   Search.ResultSet do_query_or(Search.Database.Base db,    array(string) words,    Search.RankingProfile ranking)   {    Search.ResultSet result =    _WhiteFish.do_query_or(words,    ranking->field_ranking,    ranking->proximity_ranking,    ranking->cutoff,    blobfeeder(db, words)); -  werror("do_query_or(%{ %O %}) => %d hits\n", words, result->size()); +     return result;   }      Search.ResultSet do_query_and(Search.Database.Base db,    array(string) words,    Search.RankingProfile ranking)   {    Search.ResultSet result =    _WhiteFish.do_query_and(words,    ranking->field_ranking,    ranking->proximity_ranking,    ranking->cutoff,    blobfeeder(db, words)); -  werror("do_query_and(%{ %O %}) => %d hits\n", words, result->size()); +     return result;   }      Search.ResultSet do_query_phrase(Search.Database.Base db,    array(string) words,    Search.RankingProfile ranking)   {    Search.ResultSet result =    _WhiteFish.do_query_phrase(words,    ranking->field_ranking,    // ranking->cutoff,    blobfeeder(db, words)); -  werror("do_query_phrase(%{ %O %}) => %d hits\n", words, result->size()); +     return result;   }      //! @param query   //! The query string entered by user.   //! @param db   //! The search database.   //! @param defaultRanking   //! Used when searching in the field "any:".   //!
pike.git/lib/modules/Search.pmod/Query.pmod:79:   //! @endarray   //!   array(Search.ResultSet|array(string)) execute(Search.Database.Base db,    Search.Grammar.AbstractParser parser,    string query,    Search.RankingProfile defaultRanking,    array(string)|void stop_words)   {    Search.Grammar.ParseNode q = parser->parse(query);    if (stop_words && sizeof(stop_words)) { -  werror ("Query BEFORE stop word removal:\n%O\n", q->print()); +     q = Search.Grammar.remove_stop_words(q, stop_words); -  werror ("Query AFTER stop word removal:\n%O\n", q->print()); +     }       q = Search.Grammar.optimize(q);       if (!q) // The query was a null query    return ({ Search.ResultSet(), ({}) }); // so return an empty resultset    -  werror("Query.execute:\n%s\n", q->print()); -  +     string error = Search.Grammar.validate(q);    if (error)    throw (error);       return class {    static Search.RankingProfile defaultRanking;    static Search.Database.Base db;       // Used when search is limited to another field than "any:".    static Search.RankingProfile specialRanking;
pike.git/lib/modules/Search.pmod/Query.pmod:113:    db = _db;    defaultRanking = _defaultRanking;    specialRanking = defaultRanking->copy();    }       static constant ParseNode = Search.Grammar.ParseNode;       static array(array(string)|string) words = ({ });    static array(Search.ResultSet) stack = ({ });    static void push(Search.ResultSet r) { -  // werror("---PUSH\n"); +     stack = ({ r }) + stack;    }    static Search.ResultSet pop() { -  // werror("---POP\n"); +     if (!sizeof(stack))    error("Very bad!");    Search.ResultSet r = stack[0];    stack = stack[1 .. ];    return r;    }       array(Search.ResultSet|array(string)) execute(ParseNode q) {    exec(q);    if (sizeof(stack) != 1)    throw ("Stack should have exactly one item!");    return ({ pop(), words });    }       void exec(ParseNode q) { -  // werror("EXEC %s\n", q->op); +     switch (q->op) {    case "and":    {    int first = 1;    foreach (q->children, ParseNode child)    if (child->op != "date") {    exec(child);    if (!first) {    Search.ResultSet r2 = pop();    Search.ResultSet r1 = pop();