From 78fd5304ed7bc7c04c1fec24e6c5cd26b503d73f Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 14 Feb 2018 12:25:25 -0500 Subject: [PATCH] LP#1744385: Adjust virtual-combined-class real-field search Instead of searching by combined field within the rank-addition real fields, we'll just search on the fields itself. This preserves the ranking additions provided by the real-virtual mapping. Signed-off-by: Mike Rylander Signed-off-by: Kathy Lussier Signed-off-by: Dan Wells --- .../Storage/Driver/Pg/QueryParser.pm | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 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 a763f4dd1c..9774fd0608 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 @@ -1277,29 +1277,24 @@ sub flatten { for my $real_field (@$real_fields) { $node->add_vfield($real_field); $logger->debug("Looking up virtual field for real field $real_field"); - my $vclass = $self->QueryParser->search_field_class_by_id($real_field)->{classname}; - my $vtable = $node->table($vclass); - my $vfield = 'field'; - my $vrecord = 'source'; - $from .= "\n" . ${spc} x 8 . "UNION ALL\n"; - - if ($node->combined_search) { # real fields inherit combine'dness from the virtual field - $vtable = $node->combined_table($vclass); - $vfield = 'metabib_field'; - $vrecord = 'record'; - $from .= ${spc} x 5 . "SELECT 0::BIGINT AS id, fe.record AS source, fe.metabib_field AS field, " - . "'' AS value, fe.index_vector, fe_weight.weight, ${talias}_xq.tsq, ${talias}_xq.tsq_rank /* virtual field addition */\n"; - } else { - $from .= ${spc} x 5 . "SELECT fe.id, fe.source, fe.field, fe.value, fe.index_vector, " - . "fe_weight.weight, ${talias}_xq.tsq, ${talias}_xq.tsq_rank /* virtual field addition */\n"; - } - - $from .= ${spc} x 6 . "FROM $vtable AS fe\n" + my $vtable = $node->table( + $self->QueryParser + ->search_field_class_by_id($real_field) + ->{classname} + ); + + # NOTE: only real fields that match the (component) tsquery will + # get to contribute to and increased rank for the record. + $from .= "\n" . ${spc} x 8 . "UNION ALL\n" + . ${spc} x 5 . "SELECT fe.id, fe.source, fe.field, fe.value, fe.index_vector, " + . "fe_weight.weight, ${talias}_xq.tsq, ${talias}_xq.tsq_rank /* virtual field addition */\n" + . ${spc} x 6 . "FROM $vtable AS fe\n" . ${spc} x 7 . "JOIN config.metabib_field_virtual_map AS fe_weight ON (" ."fe_weight.virtual = $possible_vfield AND " ."fe_weight.real = $real_field AND " - ."fe_weight.real = fe.$vfield)\n" - . ${spc} x 7 . "JOIN ${talias}_xq ON (fe.index_vector @@ ${talias}_xq.tsq)"; + ."fe_weight.real = fe.field)\n" + . ${spc} x 7 . "JOIN ${talias}_xq ON (fe.index_vector @@ ${talias}_xq.tsq)" + ; } } } -- 2.43.2