LucyX::Simple - Simple Lucy Interface
use LucyX::Simple; my $searcher = LucyX::Simple->new( 'index_path' => '/tmp/search_index', 'schema' => [ { 'name' => 'title', 'boost' => 3, },{ 'name' => 'description', },{ 'name' => 'id', 'type' => 'string', #you don't want the analyser to adjust your id do you? }, ], 'search_fields' => ['title', 'description'], 'search_boolop' => 'AND', ); $searcher->create({ 'id' => 1, 'title' => 'fibble', 'description' => 'wibble', }); #important - always commit after updating the index! $searcher->commit; my ( $results, $pager ) = $searcher->search( 'fibble' );
Simple interface to Lucy. Use if you want to use Lucy and are lazy, but need more than Lucy::Simple provides :p
#required args index_path => path to directory to use as index schema => arrayref of hashrefs defining schema, e.g. [ { 'name' => 'id', 'type' => 'string', }, { 'name' => 'title', 'type' => 'fulltext',' }, ]
see Lucy::Plan::FullTextType
#arguments are name => string # required type => one of qw/fulltext blob float32 float64 int32 int64 string/, default fulltext boost => float #default 1.0 indexed => 1|0 #default 1 stored => 1|0 #default sortable => 1|0 #default 0
and more, see "ADVANCED"
my ( $results, $pager ) = $searcher->search( $query, $page );
$searcher->create({ 'id' => 1, 'title' => 'this is the title', 'description' => 'this is the description', });
not that it has to be, but its highly recommended that id is a unique identifier for this document
or you'll have to pass $pk to update_or_create
$searcher->update_or_create({ 'id' => 1, 'title' => 'this is the updated title', 'description' => 'this is the description', }, 'id');
$pk is the unique key to lookup by, defaults to 'id'
$searcher->delete( 'id', 1 );
finds $key with $value and removes from index
$searcher->commit(); #or to optimise as well $searcher->commit(1);
you must call this after you have finished doing things to the index
when creating the Lucy::Simple object you can specify some advanced options
set's language for default _analyser of Lucy::Analysis::PolyAnalyzer
set analyser, defualts to Lucy::Analysis::PolyAnalyzer
fields to search by default, takes an arrayref
can be OR or AND
search boolop, defaults to or. e.g the following query
"this is search query"
becomes
"this OR is OR search OR query"
can be changed to AND, in which case the above becomes
"this AND is AND search AND query"
resultclass for results, defaults to LucyX::Simple::Result::Object which creates acessors for each key => value returned
could be changed to LucyX::Simple::Result::Hash for a plain old, hashref or a custom class
default is 100
Mark Ellis <markellis@cpan.org>
http://thisaintnews.com, Lucy, Exception::Simple
Copyright 2014 Mark Ellis <markellis@cpan.org>
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
To install LucyX::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm LucyX::Simple
CPAN shell
perl -MCPAN -e shell install LucyX::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.