Senna::Index - Interface to Senna's Index
use Senna::Index; # Export SEN_INDEX_* constants use Senna::Index qw(:flags); my $index = Senna::Index->open($path); # or my $index = Senna::Index->create($path, $flags, $n_segment, $encoding); $index->close(); $index->put($key, $value); $index->del($key, $value); $index->replace($key, $old_value, $new_value); my $cursor = $index->search($query); while (my $result = $cursor->fetch_next()) { $result->key(); $result->score(); } while ($cursor->next) { # or $cursor->rewind my $key = $cursor->key; my $score = $cursor->score; } $index->remove();
Senna::Index is an interface to the index struct in Senna (http://dev.razil.jp/projects/senna).
Creates a new senna index in a file specified by $path.
$key_size specifies the key size of the index. Currently Senna::Index only supports
SEN_VARCHAR_KEY SEN_INT_KEY
default is SEN_VARCHAR_KEY.
$flags is a bit mask, which can be a combination of
SEN_INDEX_NORMALIZE SEN_INDEX_NGRAM SEN_INDEX_SPLIT_ALPHA SEN_INDEX_SPLIT_DIGIT SEN_INDEX_SPLIT_SYMBOL
$encoding can be one of
SEN_ENC_DEFAULT SEN_ENC_NONE SEN_ENC_EUCJP SEN_ENC_UTF8 SEN_ENC_SJIS
These constants are available from Senna::Index. See CONSTANTS.
Note that senna actually creates several files for a given index. Given an index filename "senna", it will create the following files:
senna.SEN senna.SEN.i senna.SEN.i.c senna.SEN.l
Refer to the senna documentation for details.
Opens an existing senna index file.
Closes the current senna index files. Returns true on success, false otherwise.
Adds a new entry into the senna index file. Returns true on success, false otherwise.
Removes an existing entry from the senna index file. Returns true on success, false otherwise
Replaces the index that $key is pointing to from $oldval to $newval
Removes the index file opened in the current index.
Constants can are available by importing them:
use Senna::Index qw(:key_size); use Senna::Index qw(:flags); use Senna::Index qw(:encoding); use Senna::Index qw(:all);
:key_size exports SEN_VARCHAR_KEY and SEN_INT_KEY.
:key_size
:flags exports SEN_INDEX_NORMALIZE, SEN_INDEX_NGRAM, SEN_INDEX_SPLIT_ALPHA, SEN_INDEX_SPLIT_DIGIT, SEN_INDEX_SPLIT_SYMBOL.
:flags
:encoding exports SEN_ENC_DEFAULT, SEN_ENC_NONE, SEN_ENC_EUCJP, SEN_ENC_UTF8, SEN_ENC_SJIS.
:encoding
Copyright (C) 2005 by Daisuke Maki <dmaki@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
Development funded by Brazil Ltd. <http://dev.razil.jp/projects/senna/>
http://dev.razil.jp/projects/senna - Senna Development Homepage
To install Senna, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Senna
CPAN shell
perl -MCPAN -e shell install Senna
For more information on module installation, please visit the detailed CPAN module installation guide.