NAME

Mnogosearch - Perl extension for udmsearch


SYNOPSIS

  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";
  }


DESCRIPTION

Mnogosearch is a simple frontend to libudmsearch.


Creating New Mnogosearch

  $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'});
                                     


Querying Mnogosearch

$search->query(query=>'word1 word2', param1 => value1 );


Query params

query

'query' is the search string.

mode

'mode' argument can be 'all', 'any' or 'bool'.

sort

'sort' argument can be 'date' or 'rate'.

ps

'ps' define the number of results by page

pn

'pn' define the page number.


Using results infos

total_found

$search->total_found : return the total of results found.

num_pages

$search->num_pages : return the number of pages.

is_next

$search->is_next : if current page is the last one return 0, else 1.

work_time

$search->work_time : return the work time in seconds.

word_info

$search->word_info :

first

$search->first : return the first result number of the current page.

last

$search->last : return the last result number of the current page.


Using results values

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


AUTHOR

Dubun Guillaume <gdubun@gecko.fr>


SEE ALSO

perl(1).