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.31 2008/03/25 08:46:58 liin Exp $ + // $Id: Query.pmod,v 1.32 2008/03/26 18:08:53 jonasw 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:101:    Search.RankingProfile ranking,    void|array(string) stop_words,    void|search_order order)   {    Search.Grammar.ParseNode q = parser->parse(query);    if (stop_words && sizeof(stop_words))    Search.Grammar.remove_stop_words(q, stop_words);       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)    throw (error);       array(Search.ResultSet|array(string)) res = class {    static Search.RankingProfile defaultRanking;    static Search.Database.Base db;       // Used when search is limited to another field than "any:".
pike.git/lib/modules/Search.pmod/Query.pmod:275:    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*", ");    +  // Subtracting "*" gives empty result +  if (has_value(minusWordGlobs, "*")) { +  push(Search.ResultSet()); +  break; +  } +     int hasPlus = sizeof(q->plusWords) || sizeof(q->plusPhrases);    int hasOrdinary = sizeof(q->words) || sizeof(q->phrases);    int hasMinus = sizeof(q->minusWords) || sizeof(q->minusPhrases); -  +  int hasEverything = +  has_value(plusWordGlobs, "*") || +  has_value(ordinaryWordGlobs, "*"); +  if (hasEverything) { +  // FIXME: Ranking? +  push(db->get_all_documents()); +  hasPlus = 0; +  hasOrdinary = 0; +  plusWordGlobs -= ({ "*" }); +  ordinaryWordGlobs -= ({ "*" }); +  } +     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;
pike.git/lib/modules/Search.pmod/Query.pmod:358:       if(hasPlus && hasOrdinary)    {    Search.ResultSet r2 = pop();    Search.ResultSet r1 = pop();    // If a document contains must-have words AND ALSO may-have words,    // it's ranking is increased.    push(r1->add_ranking(r2));    }    -  if((hasPlus || hasOrdinary) && hasMinus) +  if((hasPlus || hasOrdinary || hasEverything) && hasMinus)    {    int first = 1;    if (sizeof(q->minusWords))    {    push(do_query_or(db, q->minusWords, ranking));    first = 0;    }    foreach(minusWordGlobs, string minusWordGlob)    {    push(do_query_or(db, db->expand_word_glob(minusWordGlob, max_globs), ranking));