From c7e2d9def2193a500b560c9bd5c98d213e3a4082 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Tue, 17 Nov 2015 17:20:05 -0500 Subject: [PATCH] LP#1516707: Phrase search ignores CD modifiers Because phrases are subqueries, we need to look at the top of the parse tree when looking for modifiers for cover density. This is because modifers are normally only allowed at the top of the parse tree (or in the floating sub- query). We do that by asking the plan's QueryParse for it's reference to its parse_tree member, which is always the top of the parse tree in QP. Included in this commit is a small change to the QP testing script to facilitate testing of this fix. Signed-off-by: Mike Rylander Signed-off-by: Kathy Lussier --- Open-ILS/src/extras/fts-replacement.pl | 7 +++++++ .../lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/extras/fts-replacement.pl b/Open-ILS/src/extras/fts-replacement.pl index c18f2e84ff..dcca275e20 100755 --- a/Open-ILS/src/extras/fts-replacement.pl +++ b/Open-ILS/src/extras/fts-replacement.pl @@ -18,6 +18,10 @@ my $query = '#available title: foo bar* || (-baz || (subject:"1900'. 'strategy(exclusion) item_type(a, t) item_form(d) '. 'bib.subjectTitle=potter bib.subjectName=harry '. 'keyword|mapscale:1:250000'; + +# For testing LP#1516707 +# $query = '#CD_documentLength #CD_meanHarmonic #CD_uniqueWords core_limit(10000) limit(1000) estimation_strategy(inclusion) keyword: title:"the blue" depth(0)'; + my $superpage = 1; my $superpage_size = 1000; my $core_limit = 25000; @@ -36,12 +40,15 @@ GetOptions( ); +OpenILS::Application::Storage::Driver::Pg::QueryParser->initialize; + my $start = time(); OpenILS::Application::Storage::Driver::Pg::QueryParser->new( superpage_size => $superpage_size, superpage => $superpage, core_limit => $core_limit, debug => $debug, query => $query )->parse->parse_tree for (1 .. $runs); my $end = time(); my $plan = OpenILS::Application::Storage::Driver::Pg::QueryParser->new( superpage_size => $superpage_size, superpage => $superpage, core_limit => $core_limit, query => $query, debug => $debug ); $plan->parse; +print "Parser config:\n" . Dumper( \%QueryParser::parser_config) if (!$quiet); print "Parsed query tree:\n" . Dumper( $plan->parse_tree) if (!$quiet); #print "Parsed query tree:\n" . Dumper( QueryParser->new( superpage_size => $superpage_size, superpage => $superpage, core_limit => $core_limit, query => $query, debug => $debug )->parse->parse_tree); my $sql = $plan->toSQL; 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 84fdbeea79..f08b1e5428 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 @@ -1526,7 +1526,7 @@ sub rank { my $cover_density = 0; for my $norm ( keys %$rank_norm_map) { - $cover_density += $$rank_norm_map{$norm} if ($self->plan->find_modifier($norm)); + $cover_density += $$rank_norm_map{$norm} if ($self->plan->QueryParser->parse_tree->find_modifier($norm)); } my $weights = join(', ', @{$self->plan->QueryParser->search_class_weights($self->classname)}); -- 2.11.0