Mnogosearch - Perl extension for udmsearch
use Mnogosearch;
# Init Mnogosearch
my $search = new Mnogosearch('DBAddr' => 'pgsql://user:password@hostname/dbname/',
'DBMode' => 'single');
# With two words, mode all,sort by rate, page size at 10 and page number at 1.
$search->query('query' => 'perl apache',
'mode' => 'all',
'sort' => 'rate',
'ps' => '10',
'pn' => 1);
# Using results.
print 'Total found : ', $search->total_found,"\n";
print 'Page Number : ', $search->page_number,"\n";
print 'Pages Number: ', $search->num_pages,"\n";
print 'Is next ? : ', $search->is_next, "\n";
print 'work time : ', $search->work_time, " seconds\n";
print 'word info :', $search->word_info, "\n";
print sprintf('Results from %d to %d ', $search->{'first'}, $search->{'last'}),"\n\n";
foreach my $result ( $search->records ) {
print sprintf('[%d] %s -> %s [%dKo]',
$result->{'url_id'},
$result->{'url'},
$result->{'title'},
$result->{'size'}/1024),"\n";
}
Mnogosearch is a simple frontend to libudmsearch.
$DBAddr = 'pgsql://user:pass@hostname/database' $DBMode = 'single'
$search = new Mnogosearch(DBAddr=>$DBAddr,
DBMode=>$DBMode);
Constructor.
If you want to use TrackQuery, you can use it like this:
$search = new Mnogosearch(DBAddr=>$DBAddr,
DBMode=>$DBMode,
TrackQuery=>yes);
IspellMode ( only db ) and LocalCharset may be specified.
$search = new Mnogosearch(DBAddr=>$DBAddr,
DBMode=>$DBMode,
LocalCharset=>'iso-8859-1',
IspellMode=>'db');
Also Affix & Spell are supported
$search = new Mnogosearch(DBAddr=>$DBAddr,
DBMode=>$DBMode,
LocalCharset=>'iso-8859-1',
Affix=>{'en'=>'en.aff',
'de'=>'/usr/local/dicts/de.aff'},
Spell=>{'en'=>'en.dict',
'de'=>'/usr/local/dicts/de.dict'});
$search->query(query=>'word1 word2', param1 => value1 );
'query' is the search string.
'mode' argument can be 'all', 'any' or 'bool'.
'sort' argument can be 'date' or 'rate'.
'ps' define the number of results by page
'pn' define the page number.
$search->total_found : return the total of results found.
$search->num_pages : return the number of pages.
$search->is_next : if current page is the last one return 0, else 1.
$search->work_time : return the work time in seconds.
$search->word_info :
$search->first : return the first result number of the current page.
$search->last : return the last result number of the current page.
my @results = $search->records;
Return a sorted array of hash ref. Each hash have the following keys defined :
category content_type description hops indexed, keywords last_index_time last_mod_time next_index_time order, rating referrer size status tag text title url url_id
Dubun Guillaume <gdubun@gecko.fr>
perl(1).