Bugzilla – Attachment 141353 Details for
Bug 17170
Add the ability to create 'saved searches' for use as filters when searching the catalog
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17170: Handle search filters in query builders
Bug-17170-Handle-search-filters-in-query-builders.patch (text/plain), 3.25 KB, created by
Nick Clemens (kidclamp)
on 2022-10-05 11:25:53 UTC
(
hide
)
Description:
Bug 17170: Handle search filters in query builders
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-10-05 11:25:53 UTC
Size:
3.25 KB
patch
obsolete
>From 37c1b4f80a2fb46f3a116fd92599e0a5d7686a43 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 17 Mar 2022 10:50:02 +0000 >Subject: [PATCH] Bug 17170: Handle search filters in query builders > >This patch updates the query building code to expand filters when searching >and pass them back as part of the cgi and descriptive search strings > >Sponsored-by: Sponsored by: Round Rock Public Library [https://www.roundrocktexas.gov/departments/library/] > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Search.pm | 3 ++- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 11 ++++++++++- > 2 files changed, 12 insertions(+), 2 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 14935ab731..076abe2cc0 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -21,6 +21,7 @@ use C4::Biblio qw( TransformMarcToKoha GetMarcFromKohaField GetFrameworkCode Get > use C4::Koha qw( getFacets GetVariationsOfISBN GetNormalizedUPC GetNormalizedEAN GetNormalizedOCLCNumber GetNormalizedISBN getitemtypeimagelocation ); > use Koha::DateUtils; > use Koha::Libraries; >+use Koha::SearchEngine::QueryBuilder; > use Lingua::Stem; > use XML::Simple; > use C4::XSLT qw( XSLTParse4Display ); >@@ -33,6 +34,7 @@ use Koha::Logger; > use Koha::Patrons; > use Koha::Recalls; > use Koha::RecordProcessor; >+use Koha::SearchFilters; > use URI::Escape; > use Business::ISBN; > use MARC::Record; >@@ -1538,7 +1540,6 @@ sub buildQuery { > } > Koha::Logger->get->debug("QUERY BEFORE LIMITS: >$query<"); > >- > # Normalize the query and limit strings > # This is flawed , means we can't search anything with : in it > # if user wants to do ccl or cql, start the query with that >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index 1791670382..554c447601 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -806,7 +806,7 @@ sub _convert_index_strings_freeform { > # Lower case field names > $search =~ s/($field_name_pattern)(?:,[\w-]*)?($multi_field_pattern):/\L$1\E$2:/og; > # Resolve possible field aliases >- $search =~ s/($field_name_pattern)($multi_field_pattern):/(exists $index_field_convert{$1} ? $index_field_convert{$1} : $1)."$2:"/oge; >+ $search =~ s/($field_name_pattern)($multi_field_pattern):/(exists $index_field_convert{$1} ? $index_field_convert{$1} : $1).($1 eq 'kw' ? "$2" : "$2:")/oge; > return $search; > } > >@@ -1069,6 +1069,15 @@ sub _fix_limit_special_cases { > next unless defined($start) && defined($end); > push @new_lim, "date-of-publication:[$start TO $end]"; > } >+ elsif( $l =~ /^search_filter:/ ){ >+ my ($filter_id) = ( $l =~ /^search_filter:(.*)$/ ); >+ my $search_filter = Koha::SearchFilters->find( $filter_id ); >+ next unless $search_filter; >+ my $expanded = $search_filter->expand_filter; >+ foreach my $e ( @{$self->_fix_limit_special_cases($expanded)} ) { >+ push @new_lim, $self->clean_search_term( $e ); >+ } >+ } > elsif ( $l =~ /^yr,st-numeric[=:]/ ) { > my ($date) = ( $l =~ /^yr,st-numeric[=:](.*)$/ ); > next unless defined($date); >-- >2.30.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 17170
:
133263
|
133264
|
133265
|
133266
|
133267
|
133268
|
133269
|
133270
|
133361
|
133376
|
137027
|
137028
|
137029
|
137030
|
137031
|
137032
|
137033
|
137034
|
137035
|
137036
|
137186
|
137187
|
137188
|
137189
|
137190
|
137191
|
137192
|
137193
|
137194
|
137195
|
137808
|
137809
|
137810
|
137811
|
137812
|
137813
|
137814
|
137815
|
137816
|
137817
|
138505
|
138506
|
138507
|
138508
|
138509
|
138510
|
138511
|
138512
|
138513
|
138514
|
139948
|
139949
|
139950
|
139951
|
139952
|
139953
|
139954
|
139955
|
139956
|
139957
|
141228
|
141229
|
141230
|
141231
|
141232
|
141233
|
141234
|
141235
|
141236
|
141237
|
141316
|
141317
|
141318
|
141319
|
141320
|
141321
|
141322
|
141323
|
141324
|
141325
|
141326
|
141327
|
141328
|
141348
|
141349
|
141350
|
141351
|
141352
|
141353
|
141354
|
141355
|
141356
|
141357
|
141358
|
141359
|
141360
|
141422
|
141423
|
141424
|
141425
|
141426
|
141427
|
141428
|
141429
|
141430
|
141431
|
141432
|
141433
|
141434
|
141435
|
141436
|
141437
|
141438
|
141461
|
141462
|
142365
|
142367
|
142368
|
142369
|
142370
|
142371
|
142372
|
142373
|
142374
|
142375
|
142376
|
142377
|
142378
|
142379
|
142380
|
142381
|
142382
|
142383
|
142384
|
142385
|
142494
|
142498