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

version» Context lines:

pike.git/lib/modules/Search.pmod/Query.pmod:8:    return db->get_blob(word, state[word]++);    };   }         Search.ResultSet do_query_or(Search.Database.Base db,    array(string) words,    Search.RankingProfile ranking)   {    array(int) word_ids=map(Array.uniq(words), db->hash_word); -  return _WhiteFish.do_query_or(word_ids, +  Search.ResultSet result = +  _WhiteFish.do_query_or(word_ids,    ranking->field_ranking,    ranking->proximity_ranking,    ranking->cutoff,    blobfeeder(db, word_ids)); -  +  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)   {    array(int) word_ids=map(Array.uniq(words), db->hash_word); -  return _WhiteFish.do_query_and(word_ids, +  Search.ResultSet result = +  _WhiteFish.do_query_and(word_ids,    ranking->field_ranking,    ranking->proximity_ranking,    ranking->cutoff,    blobfeeder(db, word_ids)); -  +  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)   {    array(int) word_ids=map(words, db->hash_word); -  return _WhiteFish.do_query_phrase(word_ids, +  Search.ResultSet result = +  _WhiteFish.do_query_phrase(word_ids,    ranking->field_ranking,    // ranking->cutoff,    blobfeeder(db, word_ids)); -  +  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:".   Search.ResultSet execute(Search.Database.Base db,    Search.Grammar.AbstractParser parser,    string query,    Search.RankingProfile defaultRanking)   {       Search.Grammar.ParseNode q = parser->parse(query);    q = Search.Grammar.optimize(q);    string error = Search.Grammar.validate(q);    if (error)    throw (error);    -  +  werror("Search.Query.execute:\n%s\n", q->print()); +     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;       static void create(Search.Database.Base _db, Search.RankingProfile _defaultRanking) {    db = _db;    defaultRanking = _defaultRanking;
pike.git/lib/modules/Search.pmod/Query.pmod:172:    Search.ResultSet r2 = pop();    Search.ResultSet r1 = pop();    push(r1 & r2);    }    first = 0;    }    }    if (hasOrdinary) {    int first = 1;    if (sizeof(q->words)) { -  push(do_query_and(db, q->words, ranking)); +  push(do_query_or(db, q->words, ranking));    first = 0;    }    foreach (q->phrases, array(string) ph) {    push(do_query_phrase(db, ph, ranking));    if (!first) {    Search.ResultSet r2 = pop();    Search.ResultSet r1 = pop();    push(r1 | r2);    }    first = 0;