# phpman > perldoc > Plucene::Search::HitCollector

## NAME
    [Plucene::Search::HitCollector](https://www.chedong.com/phpMan.php/perldoc/Plucene%3A%3ASearch%3A%3AHitCollector/markdown)

## SYNOPSIS
            # used in conjunction with the IndexSearcher

            my $searcher = [Plucene::Search::IndexSearcher](https://www.chedong.com/phpMan.php/perldoc/Plucene%3A%3ASearch%3A%3AIndexSearcher/markdown)->new($DIRECTORY);

            my $hc = [Plucene::Search::HitCollector](https://www.chedong.com/phpMan.php/perldoc/Plucene%3A%3ASearch%3A%3AHitCollector/markdown)->new( collect =>
                    sub {
                            my ($self, $doc, $score) = @_;
                            ...
            });

            $searcher->search_hc($QUERY, $hc);

## DESCRIPTION
    This is used in conjunction with the IndexSearcher, in that whenever a non-zero scoring document
    is found, the subref with with the HitCollector was made will get called.

## METHODS
  new
            my $hc = [Plucene::Search::HitCollector](https://www.chedong.com/phpMan.php/perldoc/Plucene%3A%3ASearch%3A%3AHitCollector/markdown)->new( collect =>
                    sub {
                            my ($self, $doc, $score) = @_;
                            ...
            });

    This will create a new [Plucene::Search::HitCollector](https://www.chedong.com/phpMan.php/perldoc/Plucene%3A%3ASearch%3A%3AHitCollector/markdown) with the passed subref.

  collect
    This is called once for every non-zero scoring document, with the document number and its score.

