=head1 NAME

LucyX::Simple - Simple L<Lucy> Interface

=head1 SYNOPSIS

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

=head1 DESCRIPTION

Simple interface to L<Lucy>. Use if you want to use L<Lucy> and are lazy, but need more than L<Lucy::Simple> provides :p

=head1 METHODS

=head2 new ( {hashref} )

    #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 L<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 L</ADVANCED>

=head2 B<search>( $query_string, $page ) - search index

    my ( $results, $pager ) = $searcher->search( $query, $page );

=head2 B<create>( $document ) - add item to index

    $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 I<id> is a unique identifier for this document 

or you'll have to pass $pk to update_or_create

=head2 B<update_or_create>( $document, $pk ) - updates or creates document in the index

    $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'

=head2 B<delete>( $key, $value ) - remove document from the index

    $searcher->delete( 'id', 1 );

finds $key with $value and removes from index

=head2 B<commit>() - commits and optionaly optimises index after adding documents

    $searcher->commit();

    #or to optimise as well
    $searcher->commit(1);

you must call this after you have finished doing things to the index

=head1 ADVANCED

when creating the Lucy::Simple object you can specify some advanced options

=head2 language

set's language for default _analyser of L<Lucy::Analysis::PolyAnalyzer>

=head2 analyser

set analyser, defualts to L<Lucy::Analysis::PolyAnalyzer>

=head2 search_fields

fields to search by default, takes an arrayref

=head2 search_boolop

can be I<OR> or I<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 I<AND>, in which case the above becomes

    "this AND is AND search AND query"

=head2 resultclass

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

=head2 entries_per_page

default is 100

=head1 SUPPORT

Bugs should always be submitted via the CPAN bug tracker

For other issues, contact the maintainer

=head1 AUTHORS

n0body E<lt>n0body@thisaintnews.comE<gt>

=head1 SEE ALSO

L<http://thisaintnews.com>, L<Lucy>, L<Exception::Simple>

=head1 LICENSE

Copyright (C) 2012 by n0body L<http://thisaintnews.com/>

This library is free software, you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut
