⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prefixquery.pm

📁 Plucene-1.25.tar.gz PERL版本的lucene
💻 PM
字号:
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 DESCRIPTIONA query that matches a document containing terms I<beginning> with thegiven string.=cutuse 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_stringConvert the query to a readable string format=head2 sum_squared_weightsThe sum sqaured weights of the query.=head2 normalizeNormalize the query.=cutsub 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;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -