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

version» Context lines:

pike.git/lib/modules/Search.pmod/Query.pmod:2:      static function(int:string) blobfeeder(Search.Database.Base db, array word_ids)   {    mapping state = mkmapping(word_ids,allocate(sizeof(word_ids)));    return lambda( int word )    {    return db->get_blob(word, state[word]++);    };   }    + static array(string) uniq_preserve_order(array(string) a) { +  array(string) result = ({}); +  foreach (a, string s) +  if (search(result, s) < 0) +  result += ({ s }); +  return result; + }      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); +  array(int) word_ids=map(uniq_preserve_order(words), db->hash_word);    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); +  array(int) word_ids=map(uniq_preserve_order(words), db->hash_word);    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;   }   
pike.git/lib/modules/Search.pmod/Query.pmod:200:    Search.ResultSet r1 = pop();    push(r1 | r2);    }    first = 0;    }    }       if (hasPlus && hasOrdinary) {    Search.ResultSet r2 = pop();    Search.ResultSet r1 = pop(); -  push(r1->add(r2)); +  // 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) {    int first = 1;    if (sizeof(q->minusWords)) {    push(do_query_or(db, q->minusWords, ranking));    first = 0;    }    foreach (q->minusPhrases, array(string) ph) {    push(do_query_phrase(db, ph, ranking));