This file is indexed.

/usr/share/perl5/Plucene/Search/DateFilter.pm is in libplucene-perl 1.25-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package Plucene::Search::DateFilter;
use base 'Plucene::Search::Filter';
use Carp;
use strict;
use warnings;

use Plucene::Document::DateSerializer;
use Time::Piece;
use Bit::Vector::Minimal;

=head1 NAME

Plucene::Search::DateFilter - Restrict searches to given time periods

=head1 SYNOPSIS

	my $filter = Plucene::Search::DateFilter->new({
		field => "date",
		from  => Time::Piece $from,
		to    => Time::Piece $to
	})
	my $hits = $searcher->search($query, $filter);

=head1 DESCRIPTION

This class can restrict the results of a search to a set of dates. This
requires a field to have been indexed using
L<Plucene::Document::DateSerializer>. See the documentation for that module
for how to do this.

=head1 METHODS

=head2 new

	my $filter = Plucene::Search::DateFilter->new({
		field => "date",
		from  => Time::Piece $from,
		to    => Time::Piece $to
	})

This creates a new filter. Either of C<from> or C<to> are optional.

=cut

sub new {
	my ($self, $args) = @_;
	for my $arg (qw(from to)) {
		next unless exists $args->{$arg};
		croak "$arg argument was not a Time::Piece object"
			unless UNIVERSAL::isa($args->{$arg}, "Time::Piece");
	}
	croak "Need to pass a field" unless exists $args->{field};
	no warnings 'uninitialized';
	bless {
		field => $args->{field},
		from  => freeze_date($args->{from} || Time::Piece->new(0)),
		to    => freeze_date($args->{to} || Time::Piece->new(~0)),
	}, $self;
}

=head2 bits

This is used by the searcher to iterate over the documents and return
a bitfield specifying which documents are included in the range.

=cut

sub bits {
	my ($self, $reader) = @_;
	my $bits = Bit::Vector::Minimal->new(size => $reader->max_doc);
	my $enum = $reader->terms(
		Plucene::Index::Term->new({
				field => $self->{field},
				text  => $self->{from} }));
	return $bits unless $enum->term;
	my $termdocs = $reader->term_docs;

	my $stop = Plucene::Index::Term->new({
			field => $self->{field},
			text  => $self->{to} });
	while ($enum->term->le($stop)) {
		$termdocs->seek($enum->term);
		$bits->set($termdocs->doc) while $termdocs->next;
		last unless $enum->next;
	}
	return $bits;
}

1;