-
-
27 Oct 2007 19:46:10 UTC
- Development release
- Distribution: KinoSearch
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (5)
- Testers (21 / 5 / 2)
- Kwalitee
Bus factor: 0- License: perl_5
- Activity
24 month- Tools
- Download (460.82KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors- Marvin Humphrey <marvin at rectangular dot com>
- Dependencies
- Compress::Zlib
- HTML::Parser
- Lingua::Stem::Snowball
- Lingua::StopWords
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
KinoSearch::Simple - Basic search engine.
SYNOPSIS
First, build an index of your documents.
my $index = KinoSearch::Simple->new( path => '/path/to/index/' language => 'en', ); while ( my ( $title, $content ) = each %source_docs ) { $index->add_doc({ title => $title, content => $content, }); }
Later, search the index.
my $total_hits = $index->search( query => $query_string, offset => 0, num_wanted => 10, ); print "Total hits: $total_hits\n"; while ( my $hit = $index->fetch_hit_hashref ) { print "$hit->{title}\n", }
DESCRIPTION
KinoSearch::Simple is a stripped-down interface for the KinoSearch search engine library.
METHODS
new
my $index = KinoSearch::Simple->new( path => '/path/to/index/', language => 'en', );
Create a KinoSearch::Simple object, which can be used for both indexing and searching. Two hash-style parameters are required.
path - Where the index directory should be located. If no index is found at the specified location, one will be created.
language - The language of the documents in your collection, indicated by a two-letter ISO code. 12 languages are supported:
|-----------------------| | Language | ISO code | |-----------------------| | Danish | da | | Dutch | nl | | English | en | | Finnish | fi | | French | fr | | German | de | | Italian | it | | Norwegian | no | | Portuguese | pt | | Spanish | es | | Swedish | sv | | Russian | ru | |-----------------------|
add_doc
$index->add_doc({ location => $url, title => $title, content => $content, });
Add a document to the index. The document must be supplied as a hashref, with field names as keys and content as values.
search
my $total_hits = $index->search( query => $query_string, # required offset => 40, # default 0 num_wanted => 20, # default 10 );
Search the index. Returns the total number of documents which match the query. (This number is unlikely to match
num_wanted
.)query - A search query string.
offset - The number of most-relevant hits to discard, typically used when "paging" through hits N at a time. Setting offset to 20 and num_wanted to 10 retrieves hits 21-30, assuming that 30 hits can be found.
num_wanted - The number of hits you would like to see after
offset
is taken into account.
BUGS
Not thread-safe.
COPYRIGHT
Copyright 2007 Marvin Humphrey
LICENSE, DISCLAIMER, BUGS, etc.
See KinoSearch version 0.20.
Module Install Instructions
To install KinoSearch, copy and paste the appropriate command in to your terminal.
cpanm KinoSearch
perl -MCPAN -e shell install KinoSearch
For more information on module installation, please visit the detailed CPAN module installation guide.