# phpman > man > Plucene::Index::FieldsWriter(3pm)

## NAME
    [Plucene::Index::FieldsWriter](https://www.chedong.com/phpMan.php/perldoc/Plucene%3A%3AIndex%3A%3AFieldsWriter/markdown) - writes Fields to a Document

## SYNOPSIS
            my $writer = [Plucene::Index::FieldsWriter](https://www.chedong.com/phpMan.php/perldoc/Plucene%3A%3AIndex%3A%3AFieldsWriter/markdown)->new(
                    $dir_name, $segment, $field_infos);

            $writer->add_document([Plucene::Document](https://www.chedong.com/phpMan.php/perldoc/Plucene%3A%3ADocument/markdown) $doc);

## DESCRIPTION
    This class add documents to the appropriate files.

## METHODS
  new
            my $writer = [Plucene::Index::FieldsWriter](https://www.chedong.com/phpMan.php/perldoc/Plucene%3A%3AIndex%3A%3AFieldsWriter/markdown)->new(
                    $dir_name, $segment, $field_infos);

    This will create a new [Plucene::Index::FieldsWriter](https://www.chedong.com/phpMan.php/perldoc/Plucene%3A%3AIndex%3A%3AFieldsWriter/markdown) object with the passed directory name,
    segment and field infos.

  close
            $writer->close;

  add_document
            $writer->add_document([Plucene::Document](https://www.chedong.com/phpMan.php/perldoc/Plucene%3A%3ADocument/markdown) $doc);

    This will add the passed [Plucene::Document](https://www.chedong.com/phpMan.php/perldoc/Plucene%3A%3ADocument/markdown).

