line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plucene::Document; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Plucene::Document - The unit of indexing and searching |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $document = Plucene::Document->new; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$document->add( Plucene::Document::Field $field); |
12
|
|
|
|
|
|
|
my Plucene::Document::Field $field = $document->get($field_name); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my Plucene::Document::Fields @fields = $document->fields; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Documents are the unit of indexing and search, and each document is a set |
19
|
|
|
|
|
|
|
of fields. Each field has a name and a textual value. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
A field may be stored with the document, in which case it is returned with |
22
|
|
|
|
|
|
|
search hits on the document. Thus each document should typically contain |
23
|
|
|
|
|
|
|
stored fields which uniquely identify it. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 METHODS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
18
|
|
|
18
|
|
92
|
use strict; |
|
18
|
|
|
|
|
29
|
|
|
18
|
|
|
|
|
662
|
|
30
|
18
|
|
|
18
|
|
88
|
use warnings; |
|
18
|
|
|
|
|
31
|
|
|
18
|
|
|
|
|
2324
|
|
31
|
|
|
|
|
|
|
|
32
|
18
|
|
|
18
|
|
1476
|
use base 'Class::Accessor::Fast'; |
|
18
|
|
|
|
|
37
|
|
|
18
|
|
|
|
|
16095
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(); # For new |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 get |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my Plucene::Document::Field $field = $document->get($field_name); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
This returns the Plucene::Document::Field object of the field with the |
41
|
|
|
|
|
|
|
given name if any exist in this document, or null. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub get { |
46
|
108
|
|
|
108
|
1
|
218
|
my ($obj, $field) = @_; |
47
|
108
|
|
50
|
|
|
580
|
return ($obj->{$field} || [])->[-1]; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 add |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$document->add( Plucene::Document::Field $field); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This will add a field to the document. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub add { |
59
|
1190
|
|
|
1190
|
1
|
14669
|
my ($obj, $field) = @_; |
60
|
1190
|
|
|
|
|
1566
|
push @{ $obj->{ $field->name } }, $field; |
|
1190
|
|
|
|
|
3672
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 fields |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my Plucene::Document::Field @fields = $document->fields; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This returns an list of all the fields in a document. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
1418
|
|
|
1418
|
1
|
1888
|
sub fields { map @$_, values %{ +shift } } |
|
1418
|
|
|
|
|
10372
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |