Bugzilla – Attachment 94680 Details for
Bug 23719
Record matching for authorities using defined fields is broken under ES
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23719: Allow searching specific fields for matching authorities in ES
Bug-23719-Allow-searching-specific-fields-for-matc.patch (text/plain), 3.55 KB, created by
ByWater Sandboxes
on 2019-10-24 14:49:19 UTC
(
hide
)
Description:
Bug 23719: Allow searching specific fields for matching authorities in ES
Filename:
MIME Type:
Creator:
ByWater Sandboxes
Created:
2019-10-24 14:49:19 UTC
Size:
3.55 KB
patch
obsolete
>From 6c8eb455cfd2081cc80bdc750e38713610021c26 Mon Sep 17 00:00:00 2001 >From: Nick <nick@bywatersolutions.com> >Date: Wed, 2 Oct 2019 11:17:13 +0000 >Subject: [PATCH] Bug 23719: Allow searching specific fields for matching > authorities in ES > >To test: >1 - Export your authorities via Tools->Export data >2 - Define a record matching rule in Admin->Record matchign rules > Use index: LC-card-number > field: 010$a >3 - Stage the exported records for import and use the rule created above for matching >4 - The process does not complete >5 - Check intranet error logs - exception on unknown marclist >6 - Apply patch >7 - Repeat >8 - Success! >9 - prove -v t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >--- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 6 +++--- > .../Koha/SearchEngine/Elasticsearch/QueryBuilder.t | 22 +++++++++++++++------- > 2 files changed, 18 insertions(+), 10 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index 3e63086730..c462c38981 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -500,16 +500,16 @@ sub build_authorities_query_compat { > $marclist = [map(lc, @{$marclist})]; > $orderby = lc $orderby; > >+ my @indexes; > # Make sure everything exists > foreach my $m (@$marclist) { >- Koha::Exceptions::WrongParameter->throw("Invalid marclist field provided: $m") >- unless exists $koha_to_index_name->{$m}; >+ push @indexes, exists $koha_to_index_name->{$m} ? $koha_to_index_name->{$m} : $m; > } > for ( my $i = 0 ; $i < @$value ; $i++ ) { > next unless $value->[$i]; #clean empty form values, ES doesn't like undefined searches > push @searches, > { >- where => $koha_to_index_name->{$marclist->[$i]}, >+ where => $indexes[$i], > operator => $operator->[$i], > value => $value->[$i], > }; >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >index fd983498aa..9ca04ff077 100644 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >@@ -90,7 +90,8 @@ my $clear_search_fields_cache = sub { > }; > > subtest 'build_authorities_query_compat() tests' => sub { >- plan tests => 55; >+ >+ plan tests => 56; > > my $qb; > >@@ -183,12 +184,19 @@ subtest 'build_authorities_query_compat() tests' => sub { > "authorities type code is used as filter" > ); > >- # Failing case >- throws_ok { >- $qb->build_authorities_query_compat( [ 'tomas' ], undef, undef, ['contains'], [$search_term], 'AUTH_TYPE', 'asc' ); >- } >- 'Koha::Exceptions::WrongParameter', >- 'Exception thrown on invalid value in the marclist param'; >+ # Authorities marclist check >+ $query = $qb->build_authorities_query_compat( [ 'tomas','mainentry' ], undef, undef, ['contains'], [$search_term,$search_term], 'AUTH_TYPE', 'asc' ); >+ is_deeply( >+ $query->{query}->{bool}->{must}[0]->{query_string}->{default_field}, >+ 'tomas', >+ "If no mapping for marclist the index is passed through as defined" >+ ); >+ is_deeply( >+ $query->{query}->{bool}->{must}[1]->{query_string}{default_field}, >+ 'heading', >+ "If mapping found for marclist the index is passed through converted" >+ ); >+ > }; > > subtest 'build_query tests' => sub { >-- >2.11.0
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 23719
:
93414
|
94680
|
94913
|
95001
|
95090
|
95091
|
99714