Branch: Tag:

2001-06-12

2001-06-12 09:51:28 by David Norlin <norlin@roxen.com>

API changed. AutoDoc added.

Rev: lib/modules/Search.pmod/Query.pmod:1.13
Rev: lib/modules/Search.pmod/RankingProfile.pike:1.11

67:   //! The search database.   //! @param defaultRanking   //! Used when searching in the field "any:". - Search.ResultSet execute(Search.Database.Base db, + //! + //! @returns + //! An array with two elements: + //! @array + //! @elem Search.ResultSet 0 + //! The ResultSet containing the hits. + //! @elem array(string) 1 + //! All wanted words in the query. (I.e. not the words that were + //! preceded by minus.) + //! @endarray + //! + array(Search.ResultSet|array(string)) 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);    -  if (!q) // The query was a null query -  return Search.ResultSet(); // so return an empty resultset +  if (!q) // The query was a null query +  return ({ Search.ResultSet(), ({}) }); // so return an empty resultset       string error = Search.Grammar.validate(q);    if (error)
100:       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");
114:    return r;    }    -  Search.ResultSet execute(ParseNode q) { +  array(Search.ResultSet|array(string)) execute(ParseNode q) {    exec(q);    if (sizeof(stack) != 1)    throw ("Stack should have exactly one item!"); -  return pop(); +  return ({ pop(), words });    }       void exec(ParseNode q) {
185:    if (hasPlus) {    int first = 1;    if (sizeof(q->plusWords)) { +  words += q->plusWords;    push(do_query_and(db, q->plusWords, ranking));    first = 0;    }    foreach (q->plusPhrases, array(string) ph) { -  +  words += ph;    push(do_query_phrase(db, ph, ranking));    if (!first) {    Search.ResultSet r2 = pop();
201:    if (hasOrdinary) {    int first = 1;    if (sizeof(q->words)) { +  words += q->words;    push(do_query_or(db, q->words, ranking));    first = 0;    }    foreach (q->phrases, array(string) ph) { -  +  words += ph;    push(do_query_phrase(db, ph, ranking));    if (!first) {    Search.ResultSet r2 = pop();