add phrase cross-checking
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 21 Mar 2010 18:17:22 +0000 (18:17 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 21 Mar 2010 18:17:22 +0000 (18:17 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15922 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm

index c8eb48b..8cfe876 100644 (file)
@@ -542,10 +542,14 @@ sub flatten {
                 }
 
                 my $core_limit = $self->QueryParser->core_limit || 25000;
-                $from .= "\n\t\tLIMIT " . $self->QueryParser->core_limit . "\n\t) AS " . $node->table_alias . ' ON (m.source = ' . $node->table_alias . ".source)";
+                $from .= "\n\t\tLIMIT $core_limit\n\t) AS $talias ON (m.source = $talias.source)";
                 $from .= "\n\tJOIN config.metabib_field AS ${talias}_weight ON (${talias}_weight.id = $talias.field)\n";
 
-                $where .= $node->table_alias . ".id IS NOT NULL ";
+                $where .= $talias . ".id IS NOT NULL ";
+                my $phrases = $node->phrases;
+                if (@$phrases) {
+                    $where .= ' AND (' . join(' AND ', map {"$talias.value ~ \$_$$\$$_\$_$$\$"} @$phrases) . ')';;
+                }
 
                 push @rank_list, $node_rank;