| 1 | package Search::Fulltext; | ||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 4 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 4 | our $VERSION = '1.03'; | |||||||||
| 9 | 4 | ▶ | use Search::Fulltext::SQLite; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 6 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||
| 12 | 6 | my ($class, @args) = @_; | |||||||||
| 13 | 6 | ▶ | my %args = ref $args[0] eq 'HASH' ? %{$args[0]} : @args; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | unless ($args{docs}) { croak "'docs' is required for creating new instance of $class" } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 6 | ▶ | $args{index_file} = ":memory:" unless defined $args{index_file}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 6 | ▶ | $args{tokenizer} = "simple" unless defined $args{tokenizer}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | $args{sqliteh} = Search::Fulltext::SQLite::->new( | ||||||||||
| 19 | docs => $args{docs}, | ||||||||||
| 20 | dbfile => $args{index_file}, | ||||||||||
| 21 | tokenizer => $args{tokenizer}, | ||||||||||
| 22 | 6 | ); | |||||||||
| 23 | |||||||||||
| 24 | 6 | bless { | |||||||||
| 25 | %args | ||||||||||
| 26 | }, $class; | ||||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 14 | ▶ | sub search { | ||||||||
|
Subroutine
search: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 30 | 14 | my ($self, $query) = @_; | |||||||||
| 31 | 14 | ▶ | return [] unless $query; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | |||||||||||
| 33 | 14 | my $sqliteh = $self->{sqliteh}; | |||||||||
| 34 | 14 | $sqliteh->search_docids($query); | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 4 | 1; | |||||||||
| 38 | __END__ | ||||||||||