Bugzilla – Attachment 101850 Details for
Bug 23204
Add script for exporting Elasticsearch mappings to YAML
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23204: script for exporting Elasticsearch mappings
Bug-23204-script-for-exporting-Elasticsearch-mappi.patch (text/plain), 4.16 KB, created by
Jonathan Druart
on 2020-03-26 14:16:18 UTC
(
hide
)
Description:
Bug 23204: script for exporting Elasticsearch mappings
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-03-26 14:16:18 UTC
Size:
4.16 KB
patch
obsolete
>From 999db1be1a7ac9443a1750a6390df2ae1e8abffb Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Tue, 25 Jun 2019 14:14:19 +0000 >Subject: [PATCH] Bug 23204: script for exporting Elasticsearch mappings > >Test plan: > > - launch perl misc/search_tools/export_elasticsearch_mappings.pl > > /path/to/my_mappings.yaml > - set koha-conf.elasticsearch_index_mappings to > /path/to/my_mappings.yaml, > - go to admin -> Search engine configuration, > - click on "Reset mappins", > - check that your search fields and mappings are as expected > >Signed-off-by: Bouzid Fergani <bouzid.fergani@inlibro.com> >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >Fixed commit message > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > .../export_elasticsearch_mappings.pl | 109 ++++++++++++++++++ > 1 file changed, 109 insertions(+) > create mode 100644 misc/search_tools/export_elasticsearch_mappings.pl > >diff --git a/misc/search_tools/export_elasticsearch_mappings.pl b/misc/search_tools/export_elasticsearch_mappings.pl >new file mode 100644 >index 0000000000..1668de5952 >--- /dev/null >+++ b/misc/search_tools/export_elasticsearch_mappings.pl >@@ -0,0 +1,109 @@ >+#!/usr/bin/perl >+ >+# This inserts records from a Koha database into elastic search >+ >+# Copyright 2014 Catalyst IT >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+=head1 NAME >+ >+export_elasticsearch_mappings.pl - export search_marc_map, search_marc_to_field and search_field tables to YAML >+ >+=head1 SYNOPSIS >+ >+B<export_elasticsearch_mappings.pl> >+[B<-t|--type>] >+[B<--man>] >+ >+=head1 DESCRIPTION >+ >+Export search_marc_map, search_marc_to_field and search_field tables to YAML. >+ >+=head1 OPTIONS >+ >+=over >+ >+=item B<-t|--type>=C<marc21|unimarc|normarc> >+ >+Only export a specific marc type. All if empty. >+ >+=item B<--man> >+ >+Full documentation. >+ >+=back >+ >+=head1 IMPLEMENTATION >+ >+=cut >+ >+use Modern::Perl; >+ >+use Koha::Database; >+use Koha::SearchFields; >+use Koha::SearchMarcMaps; >+ >+use YAML; >+use Getopt::Long; >+use Pod::Usage; >+ >+my $type = ''; >+my $man; >+ >+GetOptions( >+ 't|type=s' => \$type, >+ 'man' => \$man, >+); >+ >+pod2usage( -exitstatus => 0, -verbose => 2 ) if $man; >+ >+if ( $type && $type !~ /^(marc21|unimarc|normarc)$/ ) { >+ print "Bad marc type provided.\n"; >+ pod2usage(1); >+} >+ >+my $schema = Koha::Database->new()->schema(); >+ >+my $search_fields = Koha::SearchFields->search(); >+ >+my $yaml = {}; >+while ( my $search_field = $search_fields->next ) { >+ >+ my $marc_to_fields = $schema->resultset('SearchMarcToField')->search( { search_field_id => $search_field->id } ); >+ >+ while ( my $marc_to_field = $marc_to_fields->next ) { >+ my $marc_map = Koha::SearchMarcMaps->find( $marc_to_field->search_marc_map_id ); >+ >+ next if $type && $marc_map->marc_type ne $type; >+ >+ $yaml->{ $marc_map->index_name }{ $search_field->name }{label} = $search_field->label; >+ $yaml->{ $marc_map->index_name }{ $search_field->name }{type} = $search_field->type; >+ $yaml->{ $marc_map->index_name }{ $search_field->name }{facet_order} = $search_field->facet_order; >+ >+ push (@{ $yaml->{ $marc_map->index_name }{ $search_field->name }{mappings} }, >+ { >+ facet => $marc_to_field->facet || '', >+ marc_type => $marc_map->marc_type, >+ marc_field => $marc_map->marc_field, >+ sort => $marc_to_field->sort, >+ suggestible => $marc_to_field->suggestible || '' >+ }); >+ >+ } >+} >+ >+print Dump($yaml); >-- >2.20.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 23204
:
90999
|
91350
|
92022
|
92023
|
92024
|
92174
|
93524
|
95986
|
100960
|
100961
|
100962
|
100963
|
100964
|
100965
|
101742
| 101850 |
101851
|
101852
|
101853
|
101854
|
101855
|
101856
|
101857
|
101858
|
102010