From 7b8fc7b67a3c7cf3386df17950f686cef6ec5998 Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Tue, 18 Dec 2012 15:53:28 -0500 Subject: [PATCH] QueryParser: use combined metabib_field column Because I somehow forgot about it. Oops. Signed-off-by: Thomas Berezansky Signed-off-by: Lebbeous Fogle-Weekley --- .../Storage/Driver/Pg/QueryParser.pm | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm index b5fc7948ab..8914bd1605 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm @@ -998,41 +998,42 @@ sub flatten { . ${spc} x 6 . "FROM $table AS fe"; $from .= "\n" . ${spc} x 7 . "JOIN config.metabib_field AS fe_weight ON (fe_weight.id = fe.field)"; - if ($node->dummy_count < @{$node->only_atoms} ) { - $with .= ",\n " if $with; - $with .= "${talias}_xq AS (SELECT ". $node->tsquery ." AS tsq,". $node->tsquery_rank ." AS tsq_rank )"; - $from .= "\n" . ${spc} x 6 . "JOIN $ctable AS com ON (com.record = fe.source)"; - if (@{$node->fields} > 0) { - $from .= "\n" . ${spc} x 6 . "JOIN ${talias}_xq ON (com.index_vector @@ ${talias}_xq.tsq_rank AND fe.index_vector @@ ${talias}_xq.tsq)"; - } else { - $from .= "\n" . ${spc} x 6 . "JOIN ${talias}_xq ON (com.index_vector @@ ${talias}_xq.tsq)"; - } - } else { - $from .= "\n" . ${spc} x 6 . ", (SELECT NULL::tsquery AS tsq, NULL:tsquery AS tsq_rank ) AS ${talias}_xq"; - } - my @bump_fields; + my @field_ids; if (@{$node->fields} > 0) { @bump_fields = @{$node->fields}; - my @field_ids = grep defined, ( + @field_ids = grep defined, ( map { $self->QueryParser->search_field_ids_by_class( $node->classname, $_ )->[0] } @bump_fields ); + } else { + @bump_fields = @{$self->QueryParser->search_fields->{$node->classname}}; + } + + if ($node->dummy_count < @{$node->only_atoms} ) { + $with .= ",\n " if $with; + $with .= "${talias}_xq AS (SELECT ". $node->tsquery ." AS tsq,". $node->tsquery_rank ." AS tsq_rank )"; + $from .= "\n" . ${spc} x 6 . "JOIN $ctable AS com ON (com.record = fe.source"; if (@field_ids) { - $from .= "\n" . ${spc} x 6 . "WHERE fe_weight.id IN (" . - join(',', @field_ids) . ")"; + $from .= " AND com.metabib_field IN (" . join(',',@field_ids) . "))"; + } else { + $from .= " AND com.metabib_field IS NULL)"; } - + $from .= "\n" . ${spc} x 6 . "JOIN ${talias}_xq ON (com.index_vector @@ ${talias}_xq.tsq)"; } else { - @bump_fields = @{$self->QueryParser->search_fields->{$node->classname}}; + $from .= "\n" . ${spc} x 6 . ", (SELECT NULL::tsquery AS tsq, NULL:tsquery AS tsq_rank ) AS ${talias}_xq"; } - $from .= "\n" . ${spc} x 4 . ") AS $talias ON (m.source = ${talias}.source)"; + if (@field_ids) { + $from .= "\n" . ${spc} x 6 . "WHERE fe_weight.id IN (" . + join(',', @field_ids) . ")"; + } + $from .= "\n" . ${spc} x 4 . ") AS $talias ON (m.source = ${talias}.source)"; my %used_bumps; my @bumps; -- 2.43.2