File Coverage

blib/lib/Search/Query/Field/Lucy.pm
Criterion Covered Total %
statement 9 13 69.2
branch 0 2 0.0
condition 0 9 0.0
subroutine 3 4 75.0
pod 1 1 100.0
total 13 29 44.8


line stmt bran cond sub pod time code
1             package Search::Query::Field::Lucy;
2 1     1   6 use Moo;
  1         2  
  1         9  
3             extends 'Search::Query::Field';
4 1     1   392 use Scalar::Util qw( blessed );
  1         4  
  1         56  
5              
6 1     1   968 use namespace::sweep;
  1         56737  
  1         8  
7              
8             has 'type' => ( is => 'rw', default => sub {'char'} );
9             has 'is_int' => ( is => 'rw', default => sub {0} );
10             has 'analyzer' => ( is => 'rw' ); # TODO isa check
11             has 'range_query_class' =>
12             ( is => 'rw', default => sub {'Lucy::Search::RangeQuery'} );
13             has 'term_query_class' =>
14             ( is => 'rw', default => sub {'Lucy::Search::TermQuery'} );
15             has 'phrase_query_class' =>
16             ( is => 'rw', default => sub {'Lucy::Search::PhraseQuery'} );
17             has 'proximity_query_class' =>
18             ( is => 'rw', default => sub {'LucyX::Search::ProximityQuery'} );
19             has 'wildcard_query_class' =>
20             ( is => 'rw', default => sub {'LucyX::Search::WildcardQuery'} );
21             has 'nullterm_query_class' =>
22             ( is => 'rw', default => sub {'LucyX::Search::NullTermQuery'} );
23             has 'anyterm_query_class' =>
24             ( is => 'rw', default => sub {'LucyX::Search::AnyTermQuery'} );
25              
26             our $VERSION = '0.200';
27              
28             =head1 NAME
29              
30             Search::Query::Field::Lucy - query field representing a Lucy field
31              
32             =head1 SYNOPSIS
33              
34             my $field = Search::Query::Field::Lucy->new(
35             name => 'foo',
36             alias_for => [qw( bar bing )],
37             );
38              
39             =head1 DESCRIPTION
40              
41             Search::Query::Field::Lucy implements field
42             validation and aliasing in Lucy search queries.
43              
44             =head1 METHODS
45              
46             This class is a subclass of Search::Query::Field. Only new or overridden
47             methods are documented here.
48              
49             =head2 BUILD
50              
51             Available params are also standard attribute accessor methods.
52              
53             =over
54              
55             =item type
56              
57             The column type. This may be a Lucy::FieldType object
58             or a simple string.
59              
60             =item is_int
61              
62             Set if C matches m/int|num|date/.
63              
64             =item analyzer
65              
66             Set to a L-based object (optional).
67              
68             =item range_query_class
69              
70             Defaults to L.
71              
72             =item term_query_class
73              
74             Defaults to L.
75              
76             =item phrase_query_class
77              
78             Defaults to L.
79              
80             =item proximity_query_class
81              
82             Defaults to L.
83              
84             =item wildcard_query_class
85              
86             Defaults to L.
87              
88             =item nullterm_query_class
89              
90             Defaults to L.
91              
92             =item anyterm_query_class
93              
94             Defaults to L.
95              
96             =back
97              
98             =cut
99              
100             sub BUILD {
101 0     0 1   my $self = shift;
102              
103             # numeric types
104 0 0 0       if ( exists $self->{type}
      0        
      0        
105             && defined $self->{type}
106             && !blessed( $self->{type} )
107             && $self->{type} =~ m/int|date|num/ )
108             {
109 0           $self->{is_int} = 1;
110             }
111              
112             # text types
113             else {
114 0           $self->{is_int} = 0;
115             }
116              
117             }
118              
119             1;
120              
121             __END__