Liz::Nextrieve - Search with Nextrieve in a Liz::SQL database module
use Liz::Nextrieve;
$nextrieve = new Liz::Nextrieve;
#!/usr/local/bin/perl
use Liz::Nextrieve;
The Liz::Nextrieve package allows the use of the Nextrieve search engine with many added features. To be able to create these features, information about the search database (such as location and search results) is kept in a Liz::SQL compatible database.
The following methods can be called without an object specification, but as a class method such as Liz::Nextrieve->method().
Return list of identification names of all Nextrieve search engines in the database specified.
1 wildcard specification to match (default: all) 2 reference to routine that performs connect (default: &Connect from caller's namespace)
1 reference to list of identification names in the current database 2 reference to hash with full names 3 reference to hash with version info
Create a new Liz::Nextrieve object. Creates connection or re-establishes connection with the MySQL database.
1 Liz::SQL compatible handle 2 identification name of search engine (default: default search engine for database)
1 instantiated object
$hn = new HN; $search = Liz::Nextrieve->new( $hn,'hospitorg' ); $search = $hn->SearchEngine( 'hospitorg' );
Delete one or more queries from the Liz::Nextrieve database without first having to create an object for each query to be deleted.
1..N message ID's to be deleted
The following methods allow indexing for a search engine.
Index the list of files previously indicated, e.g. with a call to method Tree.
1 directory in which to place the resulting indexes (default: 'indexes') 2 type of information to be indexed (default: 'html', other values: ascii, mail and auto)
1 flag: whether successful
The following methods are related to the cached queries in the MySQL database.
Remove the queries that are older than the specified time from the currently cached in the database. Use method ResetCache to remove all cached entries from the cache.
1 expiration time of the cached queries in minutes
(default: 480 minutes = 8 hours)
1..N ID's of queries that have been removed
$search->CleanCache; $search->CleanCache( 4*60 );
Return all queries that have currently been cached in the database since the last time the Nextrieve database was re-indexed.
1..N queries that were entered
$queries = join( "\n",$search->Queries ); print "The following queries are cached:\n$queries\n";
Remove all queries currently cached in the database. Use method CleanCache to only deletee entries older than a specific number of minutes.
$search->ResetCache;
Return the mappedname field of a specific hit (indicated by ordinal number) of a specific cached query (indicated by ID). Usually used for click-through pages. In some applications (e.g. Search.NL), the mappedname field is actually used as a URL.
1 ID of the query of which to return the mappedname 2 ordinal number of hit of which to return the mappedname (default: 1)
1 mappedname of the indicated hit
<PERL>Redirect( 'http:/'.SearchNL->new->SearchEngine->MappedName( $ID,$hit ) )</PERL>
The following methods allow indexing for a search engine.
Search for the indicated query in the database.
1 query to search for 2 first search result to be returned (default: 1) 3 number of search results to return (default: rest)
1 number of hits returned 2 number of hits found
Fetch a row of the search result as specified with the Fields method. Automatically fetches next row of the search result if no specific entry is specified.
1 entry in result list of which to obtain row (default: next, starts at value specified with Search)
1 array with values in order of fields specification
The following methods allow changes to information that is associated with an entire search engine.
Return whether the last search result was already cached in the mySQL database before the query was done.
1 flag: whether result of query was cached
Return the ID with which the query was cached in the MySQL database.
1 ID with which the query was cached
Specify or return the current name of the search engine.
1 new name of the search engine (default: no change)
1 current/old name of nextrieve
Specify or return the current Nextrieve resource information of the object. Is usually called internally only, but can also be use from the ``outside''.
1 new resource information (default: no change)
1 current/old resource information
The following methods can be easy to use with a search engine.
Return the HTML code to display to create a dual row of buttons to allow the user to page through the search result.
1 directory in which images are located 2 height of images to be used (the same for all) 3 name of image for previous entry 4 width of image for previous entry 5 name of image for current entry 6 width of image for current entry 7 name of image for other entry 8 width of image for other entry 9 name of image for next entry 10 width of image for next entry
1 HTML (if any) to be inserted
</PERL> $buttons = $search->PreviousNext( '/vsb',15, 'b_vorige.gif',35, 'b_niet.gif',11, 'b_wel.gif',11, 'b_volgen.gif',41 ); </PERL> <IF $buttons> <FORM><HIDDEN query $query><HIDDEN fuzzy $fuzzy>$buttons</FORM> <ENDIF>
Elizabeth Mattijsen ( lizperl@INC.nl )
(C) 1998-1999 International Network Consultants
Method PreviousNext now does not set width and height of current and other image if it is not the first batch of results. This should save almost 1 K in traffic per subsequent request on Search.NL.
Methods Name and Resource now call TableMeta in a scalar context to prevent side-effects of the list context behaviour of TableMeta.
Now no longer adds Exporter to ISA: it wasn't necessary.
Method CleanCache now returns the ID's of the queries that have been removed.
Method CleanCache now correctly calculates the timestamp: before the timestamp was calculated in GMT. now correctly calculates the timestamp: before the timestamp was calculated in GMT.
Added LOCK TABLES sections around DELETE in <CleanCache> as the absence seems to place MySQL in a deadlock position, and thus lets MySQL crash on Search.NL.
Adapted method CleanCache in such a way that the cleaning is not done in 2 large queries, but instead in a lot of smaller queries, causing less interference with search queries of other processes.
New method MappedName added: return the filename of a specific cached query and hit number.
New method CleanCache added: clean the cache of entries older than a specific number of minutes.
Method Search now updates the ``requested'' field in the database so that a record is kept of how many times a cached query was used.
New method ResetCache, to reset the database cache. Adapted Index to call this method.
Class method engines now calls Liz::SQL's ``sets'' to create list.
Method new now calls Liz::SQL's ``new'' to create database handle.
Changed to new source typography.
Changed all CREATE TABLEs to the new Liz::SQL 'create' method.
Changed from using method ``Exists'' to ``Count'' in method new so that it can check for the existence of a table much more quickly.
Changed database format so that large previews, as a result of preview appending for identical files when using the distinct option, ar now also allowed, well up to 64K that is.
Added support for Distinct option in the Nextrieve.pm module. It is now possible to indicate to only receive different filenames in the result, even if there is more than one match in a file.
Added support for database version upgrade.
Reduced memory footprint by only using fully qualified global variables.
New method Queries returns the queries that are currently cached already.
Method Search now sets the query cached flag. Also, empty result lists are no longer cached, preventing Nextrieve errors from polluting the SQL database from faulty results.
New method Cached returns whether the result of a query was cached in the SQL database.
Simplified method delete to use single queries instead of a loop.
Method engines now returns a reference to a hash for the names instead of just another list.
New method PreviousNext added: returns HTML for a bar with buttons from which the user may select a page of the search result.
First version of this true Perl module.