/usr/share/perl5/Plucene/Search/PrefixQuery.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 | package Plucene::Search::PrefixQuery;
=head1 NAME
Plucene::Search::TermQuery - a query that matches terms beginning with a string
=head1 SYNOPSIS
# isa Plucene::Search::Query
$prefix_query->normalize($norm);
my $ssw = $prefix_query->sum_squared_weights($searcher);
my $as_string = $prefix_query->to_string($field);
=head1 DESCRIPTION
A query that matches a document containing terms I<beginning> with the
given string.
=cut
use strict;
use warnings;
use base 'Plucene::Search::Query';
use Plucene::Search::BooleanQuery;
use Plucene::Search::TermQuery;
__PACKAGE__->mk_accessors(qw/ prefix reader /);
sub prepare { $_[0]->reader($_[1]) }
# This returns the underlying boolean query.
sub _query {
my $self = shift;
return $self->{query} if exists $self->{query};
my $q = new Plucene::Search::BooleanQuery;
my $prefix = $self->prefix;
my $enum = $self->reader->terms($prefix);
my ($field, $text) = ($prefix->field, $prefix->text);
do {
my $term = $enum->term;
goto DONE
unless $term
and $term->text =~ /^\Q$text/
and $term->field eq $field;
my $tq = Plucene::Search::TermQuery->new({ term => $term });
$tq->boost($self->boost);
$q->add($tq, 0, 0);
} while $enum->next;
DONE: $self->{query} = $q;
}
=head2 to_string
$q->to_string
Convert the query to a readable string format
=head2 sum_squared_weights
The sum sqaured weights of the query.
=head2 normalize
Normalize the query.
=cut
sub to_string {
my ($self, $field) = @_;
my $s = "";
$s = $self->prefix->field . ":" if $self->prefix->field ne $field;
$s .= $self->prefix->text . "*";
$s .= "^" . $self->boost unless $self->boost == 1;
$s;
}
sub sum_squared_weights { shift->_query->sum_squared_weights(@_) }
sub normalize { shift->_query->normalize(@_) }
sub _scorer { shift->_query->_scorer(@_) }
1;
|