Perl Diver 2.33
Main Environment Variables Perl Default Values Perl Config - Summary Perl Config - Full Installed Modules List Directory uptime Docs

Module Documentation
Details and documentation about a specific module, including version and documentation (if available). Note that while links to perldoc.com and search.cpan.org are provided, the module may be part of a larger distribution. If you reach a File Not Found page on either site, please try the parent module.

Plucene::Index::FieldInfos

Name Plucene::Index::FieldInfos
Version
Located at /usr/share/perl5
File /usr/share/perl5/Plucene/Index/FieldInfos.pm
Is Core No
Search CPAN for this module Plucene::Index::FieldInfos
Documentation Plucene::Index::FieldInfos
Module Details Plucene::Index::FieldInfos

NAME

Plucene::Index::FieldInfos - a collection of FieldInfo objects


SYNOPSIS

        my $fis = Plucene::Index::FieldInfos->new($dir_name);
        my $fis = Plucene::Index::FieldInfos->new($dir_name, $file);
        $fis->add(Plucene::Document $doc, $indexed);
        $fis->add(Plucene::Index::FieldInfos $other_fis, $indexed);
        $fis->add($name, $indexed);
        $fis->write($path);
        my @fields = $fis->fields;
        my $field_number = $fis->field_number($name);
        my   $field_info = $fis->field_info($name);
        my   $field_name = $fis->field_name($number);
        my   $num_fields = $fis->size;


DESCRIPTION

This is a collection of field info objects, which happen to live in the field infos file.


METHODS

new

        my $fis = Plucene::Index::FieldInfos->new($dir_name);
        my $fis = Plucene::Index::FieldInfos->new($dir_name, $file);

This will create a new Plucene::Index::FieldInfos object with the passed directory and optional filename.


=cut

sub new { my ($class, $dir, $file) = @_; my $self = bless {}, $class; $file ? $self->_read(``$dir/$file'') : $self->_add_internal(``'', 0); return $self; }

add

        $fis->add(Plucene::Document $doc, $indexed);
        $fis->add(Plucene::Index::FieldInfos $other_fis, $indexed);
        $fis->add($name, $indexed);

This will add the fields from a Plucene::Document or a Plucene::Index::FieldsInfos to the field infos file.

It is also possible to pass the name of a field and have it added to the file.


=cut

sub add { my ($self, $obj, $indexed) = @_; if ( UNIVERSAL::isa($obj, ``Plucene::Document'') or UNIVERSAL::isa($obj, ``Plucene::Index::FieldInfos'')) { $self->add($_->name, $_->is_indexed) for $obj->fields; return; } confess ``Don't yet know how to handle a $obj'' if ref $obj; my $name = $obj; # For clarity. :) my $fi = $self->field_info($name); $fi ? $fi->is_indexed($indexed) : $self->_add_internal($name, $indexed); }

sub _add_internal { my ($self, $name, $indexed) = @_; my $fi = Plucene::Index::FieldInfo->new( name => $name, is_indexed => $indexed, number => $#{ $self->{bynumber} } + 1, ); push @{ $self->{bynumber} }, $fi; $self->{byname}{$name} = $fi; }

field_number

        my $field_number = $fis->field_number($name);

This will return the field number of the field with $name. If there is no match, then -1 is returned.


=cut

sub field_number { my ($self, $name) = @_; return -1 unless defined $name; my $field = $self->{byname}{$name} or return -1; return $field->number; }

fields

        my @fields = $fis->fields;

This will return all the fields.

field_info

        my $field_info = $fis->field_info($name);

This will return the field info for the field called $name.

field_name

        my $field_name = $fis->field_name($number);

This will return the field name for the field whose number is $number.

size

        my $num_fields = $fis->size;

This returns the number of field info objects.

write

        $fis->write($path);

This will write the field info objects to $path.

Perl Diver brought to you by ScriptSolutions.com © 1997- 2026