#-------------------------------
package OpenILS::Application::Storage::Driver::Pg::QueryParser::query_plan;
use base 'QueryParser::query_plan';
+use OpenSRF::Utils::Logger qw($logger);
+use Data::Dumper;
sub toSQL {
my $self = shift;
$self->QueryParser->superpage_size($filters{superpage_size}) if ($filters{superpage_size});
$self->QueryParser->core_limit($filters{core_limit}) if ($filters{core_limit});
+ $logger->debug("Query plan:\n".Dumper($self));
+
my $flat_plan = $self->flatten;
# generate the relevance ranking
my $self = shift;
my $from = shift || '';
- my $where = shift || '';
+ my $where = shift || '(';
my @rank_list;
for my $node ( @{$self->query_nodes} ) {
}
}
- return { rank_list => \@rank_list, from => $from, where => $where };
+ return { rank_list => \@rank_list, from => $from, where => $where.')' };
}
$last_type = '';
} elsif ($self->search_class_count && /$search_class_re/) { # changing current class
+
+ if ($last_type eq 'CLASS') {
+ $struct->remove_last_node( $current_class );
+ warn "Encountered class change with no searches!\n" if $self->debug;
+ }
+
warn "Encountered class change: $1\n" if $self->debug;
$current_class = $1;
$struct->classed_node( $current_class );
$_ = $';
- $last_type = '';
+ $last_type = 'CLASS';
} elsif (/^\s*"([^"]+)"/) { # phrase, always anded
warn "Encountered phrase: $1\n" if $self->debug;
return $node;
}
+sub remove_last_node {
+ my $self = shift;
+ my $requested_class = shift;
+
+ my $old = pop(@{$self->query_nodes});
+ pop(@{$self->query_nodes}) if (@{$self->query_nodes});
+
+ return $old;
+}
+
sub query_nodes {
my $self = shift;
return $self->{query};