line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plucene::Search::Searcher; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Plucene::Search::Searcher - base class for searchers |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Abstract base class for searchers. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Searching is the operation of locating a subset of the documents that |
12
|
|
|
|
|
|
|
contains desired content or that their attributes match some specification. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
The input for a search operation is a 'query' that specifies a criteria for |
15
|
|
|
|
|
|
|
selecting the documents and its output is a list of documents ('hits') that |
16
|
|
|
|
|
|
|
matched that criteria. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
The hit list is typically ordered by some measure of relevancy (called |
19
|
|
|
|
|
|
|
'ranking' or 'scoring') and may contain only a subset of the set of documents |
20
|
|
|
|
|
|
|
that matched the query (typically the ones with the highest scored documents). |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
The search operation is performed on an 'index' which is a specialized |
23
|
|
|
|
|
|
|
database that contains a pre compiled information of the document set. |
24
|
|
|
|
|
|
|
The index database is optimized for locating quickly documents that contains |
25
|
|
|
|
|
|
|
certain words or terms. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 METHODS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
16
|
|
|
16
|
|
103
|
use strict; |
|
16
|
|
|
|
|
36
|
|
|
16
|
|
|
|
|
569
|
|
32
|
16
|
|
|
16
|
|
88
|
use warnings; |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
396
|
|
33
|
|
|
|
|
|
|
|
34
|
16
|
|
|
16
|
|
8728
|
use Plucene::Search::Hits; |
|
16
|
|
|
|
|
50
|
|
|
16
|
|
|
|
|
129
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 doc_freq / max_doc / doc / _search_hc search_top |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
These must be defined in a subclas |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
0
|
1
|
0
|
sub doc_freq { die "doc_freq must be defined in a subclass" } |
43
|
0
|
|
|
0
|
1
|
0
|
sub max_doc { die "max_doc must be defined in a subclass" } |
44
|
0
|
|
|
0
|
1
|
0
|
sub doc { die "doc must be defined in a subclass" } |
45
|
0
|
|
|
0
|
|
0
|
sub _search_hc { die "_search_hc must be defined in a subclass" } |
46
|
0
|
|
|
0
|
1
|
0
|
sub search_top { die "search_top must be defined in a subclass" } |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 search |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my Plucene::Search::Hits $hits = $searcher->new($query, $filter); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
This will return the Plucene::Search::Hits object for the passed in query |
53
|
|
|
|
|
|
|
and filter. At this stage, filter is optional. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub search { |
58
|
176
|
|
|
176
|
1
|
383
|
my ($self, $query, $filter) = @_; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# $filter may be undefined, that's OK |
61
|
176
|
|
|
|
|
2040
|
return Plucene::Search::Hits->new({ |
62
|
|
|
|
|
|
|
searcher => $self, |
63
|
|
|
|
|
|
|
query => $query, |
64
|
|
|
|
|
|
|
filter => $filter |
65
|
|
|
|
|
|
|
}); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 search_hc |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub search_hc { |
73
|
2
|
|
|
2
|
1
|
909
|
my ($self, $query, $hc) = @_; |
74
|
2
|
|
|
|
|
8
|
$self->_search_hc($query, undef, $hc); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |