| 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 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 30 | 18 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 31 | |||||||||||||
| 32 | 18 | ▶ | use base 'Class::Accessor::Fast'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 33 | |||||||||||||
| 34 | 18 | __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 | 210 | ▶ | sub get { | ||||||||||
|
Subroutine
get: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||
| 46 | 210 | my ($obj, $field) = @_; | |||||||||||
| 47 | 210 | ▶ | return ($obj->{$field} || [])->[-1]; | ||||||||||
|
Condition50%1/2
$obj->{$field} || []
MC/DC0%0/1
$obj->{$field} || []
$obj->{$field}
Truth table50%1/2
A
A= $obj->{$field}
| |||||||||||||
| 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 | 1496 | ▶ | sub add { | ||||||||||
|
Subroutine
add: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 59 | 1496 | my ($obj, $field) = @_; | |||||||||||
| 60 | 1496 | push @{ $obj->{ $field->name } }, $field; | |||||||||||
| 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 | ▶ | sub fields { map @$_, values %{ +shift } } | ||||||||||
|
Subroutine
fields: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 72 | |||||||||||||
| 73 | 18 | 1; | |||||||||||