Bugzilla – Attachment 68704 Details for
Bug 16660
Elasticsearch broken if OpacSuppression is activated
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16660: Moved Opac Supression filtering from opac-search.pl to Zebra::QueryBuilder
Bug-16660-Moved-Opac-Supression-filtering-from-opa.patch (text/plain), 4.94 KB, created by
Kyle M Hall (khall)
on 2017-10-27 13:34:08 UTC
(
hide
)
Description:
Bug 16660: Moved Opac Supression filtering from opac-search.pl to Zebra::QueryBuilder
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2017-10-27 13:34:08 UTC
Size:
4.94 KB
patch
obsolete
>From bb2749ddd8ef4fe2a2547506378c812df72b317f Mon Sep 17 00:00:00 2001 >From: Srdjan <srdjan@catalyst.net.nz> >Date: Tue, 28 Feb 2017 15:17:49 +1300 >Subject: [PATCH] Bug 16660: Moved Opac Supression filtering from > opac-search.pl to Zebra::QueryBuilder > >To test: >OPAC: Both SearchEngine "Elasticsearch" and "Zebra" should work with >OpacSuppression set to "yes" > >NB: OPAC suppression is not implemented for Elasticsearch > >Signed-off-by: David Bourgault <david.bourgault@inlibro.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/SearchEngine/Zebra/QueryBuilder.pm | 26 ++++++++++++++-- > opac/opac-search.pl | 55 ++++++++++++++------------------- > 2 files changed, 47 insertions(+), 34 deletions(-) > >diff --git a/Koha/SearchEngine/Zebra/QueryBuilder.pm b/Koha/SearchEngine/Zebra/QueryBuilder.pm >index d0e2738..8021eff 100644 >--- a/Koha/SearchEngine/Zebra/QueryBuilder.pm >+++ b/Koha/SearchEngine/Zebra/QueryBuilder.pm >@@ -30,9 +30,29 @@ sub build_query { > } > > sub build_query_compat { >- # Because this passes directly on to C4::Search, we have no trouble being >- # compatible. >- build_query(@_); >+ my $self = shift; >+ my ($operators, $operands, $indexes, $limits, $sort_by, $scan, $lang, $params) = @_; >+ >+ my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type) >+ = $self->build_query(@_); >+ >+ # add OPAC 'hidelostitems' >+ #if (C4::Context->preference('hidelostitems') == 1) { >+ # # either lost ge 0 or no value in the lost register >+ # $query ="($query) and ( (lost,st-numeric <= 0) or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='') )"; >+ #} >+ # >+ # add OPAC suppression - requires at least one item indexed with Suppress >+ if ($params->{suppress}) { >+ if ( $query_type eq 'pqf' ) { >+ #$query = "($query) && -(suppress:1)"; #QP syntax >+ $query = '@not '.$query.' @attr 14=1 @attr 1=9011 1'; #PQF syntax >+ } else { >+ $query = "($query) not Suppress=1"; >+ } >+ } >+ >+ return ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type); > } > > sub build_authorities_query { >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 133b671..ccde617 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -532,8 +532,31 @@ my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_ > > my @results; > >+my $suppress = 0; >+if (C4::Context->preference('OpacSuppression')) { >+ # OPAC suppression by IP address >+ if (C4::Context->preference('OpacSuppressionByIPRange')) { >+ my $IPAddress = $ENV{'REMOTE_ADDR'}; >+ my $IPRange = C4::Context->preference('OpacSuppressionByIPRange'); >+ $suppress = ($IPAddress !~ /^$IPRange/); >+ } >+ else { >+ $suppress = 1; >+ } >+} >+ > ## I. BUILD THE QUERY >-( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type) = $builder->build_query_compat(\@operators,\@operands,\@indexes,\@limits,\@sort_by, 0, $lang, { expanded_facet => $expanded_facet }); >+( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type) >+ = $builder->build_query_compat( >+ \@operators, >+ \@operands, >+ \@indexes, >+ \@limits, >+ \@sort_by, >+ 0, >+ $lang, >+ { expanded_facet => $expanded_facet, suppress => $suppress } >+ ); > > sub _input_cgi_parse { > my @elements; >@@ -553,36 +576,6 @@ $template->param ( QUERY_INPUTS => \@query_inputs ); > ## parse the limit_cgi string and put it into a form suitable for <input>s > my @limit_inputs = $limit_cgi ? _input_cgi_parse($limit_cgi) : (); > >-# add OPAC 'hidelostitems' >-#if (C4::Context->preference('hidelostitems') == 1) { >-# # either lost ge 0 or no value in the lost register >-# $query ="($query) and ( (lost,st-numeric <= 0) or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='') )"; >-#} >-# >-# add OPAC suppression - requires at least one item indexed with Suppress >-if (C4::Context->preference('OpacSuppression')) { >- # OPAC suppression by IP address >- if (C4::Context->preference('OpacSuppressionByIPRange')) { >- my $IPAddress = $ENV{'REMOTE_ADDR'}; >- my $IPRange = C4::Context->preference('OpacSuppressionByIPRange'); >- if ($IPAddress !~ /^$IPRange/) { >- if ( $query_type eq 'pqf' ) { >- $query = '@not '.$query.' @attr 14=1 @attr 1=9011 1'; >- } else { >- $query = "($query) not Suppress=1"; >- } >- } >- } >- else { >- if ( $query_type eq 'pqf' ) { >- #$query = "($query) && -(suppress:1)"; #QP syntax >- $query = '@not '.$query.' @attr 14=1 @attr 1=9011 1'; #PQF syntax >- } else { >- $query = "($query) not Suppress=1"; >- } >- } >-} >- > $template->param ( LIMIT_INPUTS => \@limit_inputs ); > $template->param ( OPACResultsSidebar => C4::Context->preference('OPACResultsSidebar')); > >-- >2.10.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16660
:
60727
|
68224
|
68280
|
68320
|
68321
|
68322
| 68704 |
68705
|
68706