Bugzilla – Attachment 130288 Details for
Bug 25669
ElasticSearch 6: [types removal] Specifying types in put mapping requests is deprecated (incompatible with 7)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25669: ElasticSearch 6: [types removal] Specifying types in put mapping requests is deprecated (incompatible with 7)
Bug-25669-ElasticSearch-6-types-removal-Specifying.patch (text/plain), 3.87 KB, created by
Kevin Carnes
on 2022-02-08 14:40:20 UTC
(
hide
)
Description:
Bug 25669: ElasticSearch 6: [types removal] Specifying types in put mapping requests is deprecated (incompatible with 7)
Filename:
MIME Type:
Creator:
Kevin Carnes
Created:
2022-02-08 14:40:20 UTC
Size:
3.87 KB
patch
obsolete
>From 01a773474b973ef14c8fb53ee6f9badf23abf49f Mon Sep 17 00:00:00 2001 >From: Kevin Carnes <kevin.carnes@ub.lu.se> >Date: Tue, 8 Feb 2022 14:14:11 +0100 >Subject: [PATCH] Bug 25669: ElasticSearch 6: [types removal] Specifying types > in put mapping requests is deprecated (incompatible with 7) > >Starting with version 7.0 of Elasticsearch type names should not be used and >in version 6.8 there is a warning if you don't use include_type_name when >using put_mapping (requires Search::Elasticsearch@6.8). > >To test: >1) Reindex records with koha-elasticsearch or rebuild_elasticsearch.pl >2) Observe any deprecation warnings or errors >3) Apply patch >4) Install Search::Elasticsearch with the same version as Elasticsearch >5) Reindex records with koha-elasticsearch or rebuild_elasticsearch.pl >6) Observe no warning or errors >7) Sign off > >Sponsored-by: Lund University Library >--- > Koha/SearchEngine/Elasticsearch/Indexer.pm | 30 +++++++++++++++------- > 1 file changed, 21 insertions(+), 9 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch/Indexer.pm b/Koha/SearchEngine/Elasticsearch/Indexer.pm >index 0a10832d2e..4ef45f84db 100644 >--- a/Koha/SearchEngine/Elasticsearch/Indexer.pm >+++ b/Koha/SearchEngine/Elasticsearch/Indexer.pm >@@ -21,6 +21,7 @@ use Carp qw( carp croak ); > use Modern::Perl; > use Try::Tiny qw( catch try ); > use List::Util qw( any ); >+use version; > use base qw(Koha::SearchEngine::Elasticsearch); > > use Koha::Exceptions; >@@ -115,11 +116,14 @@ sub update_index { > if (@body) { > try{ > my $elasticsearch = $self->get_elasticsearch(); >- $response = $elasticsearch->bulk( >+ my %es_bulk = ( > index => $self->index_name, >- type => 'data', # is just hard coded in Indexer.pm? > body => \@body > ); >+ if (version->parse($elasticsearch->info->{version}->{number}) < version->parse('7.0.0')) { >+ $es_bulk{'type'} = 'data'; >+ } >+ $response = $elasticsearch->bulk(%es_bulk); > if ($response->{errors}) { > carp "One or more ElasticSearch errors occurred when indexing documents"; > } >@@ -252,13 +256,18 @@ sub update_mappings { > > foreach my $type (keys %{$mappings}) { > try { >- my $response = $elasticsearch->indices->put_mapping( >+ my %es_mapping = ( > index => $self->index_name, >- type => $type, >- body => { >- $type => $mappings->{$type} >- } >+ body => $mappings->{$type} > ); >+ if (version->parse($elasticsearch->info->{version}->{number}) < version->parse('7.0.0')) { >+ if (version->parse($elasticsearch->info->{version}->{number}) >= version->parse('6.8.0') && version->parse($elasticsearch->VERSION) >= version->parse('6.8.0')) { >+ $es_mapping{'include_type_name'} = \1; >+ } >+ $es_mapping{'type'} = 'data'; >+ $es_mapping{'body'} = {'data' => $mappings->{$type}}; >+ } >+ my $response = $elasticsearch->indices->put_mapping(%es_mapping); > } catch { > $self->set_index_status_recreate_required(); > my $reason = $_[0]->{vars}->{body}->{error}->{reason}; >@@ -346,11 +355,14 @@ sub delete_index { > > my $elasticsearch = $self->get_elasticsearch(); > my @body = map { { delete => { _id => "$_" } } } @{$biblionums}; >- my $result = $elasticsearch->bulk( >+ my %es_bulk = ( > index => $self->index_name, >- type => 'data', > body => \@body, > ); >+ if (version->parse($elasticsearch->info->{version}->{number}) < version->parse('7.0.0')) { >+ $es_bulk{'type'} = 'data'; >+ } >+ my $result = $elasticsearch->bulk(%es_bulk); > if ($result->{errors}) { > croak "An Elasticsearch error occurred during bulk delete"; > } >-- >2.17.1
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 25669
:
130288
|
130293
|
130341
|
130811
|
131009
|
131037
|
131484
|
132321
|
135335
|
135542
|
135543
|
136417
|
136418
|
136452
|
136453
|
139531
|
139532