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.30 2004/12/29 13:27:22 anders Exp $ + // $Id: Query.pmod,v 1.31 2008/03/25 08:46:58 liin Exp $      static function(string,int:string) blobfeeder(Search.Database.Base db,    array words)   {    mapping state = mkmapping(words,allocate(sizeof(words)));    mapping(string:mapping(int:string)) blobcache = ([ ]);    return lambda( string word, int foo )    {    return db->get_blob(word, state[word]++, blobcache);    };
pike.git/lib/modules/Search.pmod/Query.pmod:83:   //! Used when searching in the field "any:".   //!   //! @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.) + //! @elem array(string) 2 + //! All wanted globs in the query. (I.e. not the globs that were + //! preceded by minus.)   //! @endarray   //!   array(Search.ResultSet|array(string)) execute(Search.Database.Base db,    Search.Grammar.AbstractParser parser,    string query,    Search.RankingProfile ranking,    void|array(string) stop_words,    void|search_order order)   {    Search.Grammar.ParseNode q = parser->parse(query);
pike.git/lib/modules/Search.pmod/Query.pmod:134:    if(has_value(word, "*") || has_value(word, "?"))    b+=({ word });    else    a+=({ word });    return ({ a, b });    }       static constant ParseNode = Search.Grammar.ParseNode;       static array(array(string)|string) words = ({ }); +  static array(array(string)|string) glob_words = ({ });    static ADT.Stack stack = ADT.Stack();    static function(Search.ResultSet:void) push;    static function(void:Search.ResultSet) pop;       array(Search.ResultSet|array(string)) execute(ParseNode q) {    exec(q);    if (sizeof(stack) != 1)    error("Stack should have exactly one item!"); -  return ({ pop(), words }); +  return ({ pop(), words, glob_words });    }          void exec(ParseNode q) {    int max_globs = 100;    switch (q->op) {    case "and":    {    int first = 1;    foreach (q->children, ParseNode child)
pike.git/lib/modules/Search.pmod/Query.pmod:268:    break;    }    ranking->field_ranking = allocate(65);    ranking->field_ranking[fieldID] = 1;    }       [array plusWords, array plusWordGlobs] = split_words(q->plusWords);    [array ordinaryWords, array ordinaryWordGlobs] = split_words(q->words);    [array minusWords, array minusWordGlobs] = split_words(q->minusWords);    +    // werror("[%-10s] plus: %-15s ordinary: %-15s minus: %-15s\n", q->field, q>plusWords*", ", q->words*", ", q->minusWords*", ");       int hasPlus = sizeof(q->plusWords) || sizeof(q->plusPhrases);    int hasOrdinary = sizeof(q->words) || sizeof(q->phrases);    int hasMinus = sizeof(q->minusWords) || sizeof(q->minusPhrases); -  +  glob_words += Array.uniq(plusWordGlobs | ordinaryWordGlobs);       if(hasPlus)    {    int first = 1;    if(sizeof(plusWords))    {    words += plusWords;    push(do_query_and(db, plusWords, ranking));    first = 0;    } -  +     foreach(plusWordGlobs, string plusWordGlob)    {    push(do_query_or(db, db->expand_word_glob(plusWordGlob, max_globs), ranking));    if (!first)    {    Search.ResultSet r2 = pop();    Search.ResultSet r1 = pop();    push(r1 & r2);    }    first = 0;