Bugzilla – Attachment 43345 Details for
Bug 12478
Elasticsearch support for Koha
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12478: [DO NOT PUSH] script to generate the mappings yaml file
Bug-12478-DO-NOT-PUSH-script-to-generate-the-mappi.patch (text/plain), 4.23 KB, created by
Jonathan Druart
on 2015-10-12 16:17:38 UTC
(
hide
)
Description:
Bug 12478: [DO NOT PUSH] script to generate the mappings yaml file
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-10-12 16:17:38 UTC
Size:
4.23 KB
patch
obsolete
>From bfd7a474c7a7c41cf7e42d59e6d21c2889f586b8 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 12 Oct 2015 16:45:48 +0100 >Subject: [PATCH] Bug 12478: [DO NOT PUSH] script to generate the mappings yaml > file > >--- > mappings_to_yaml.pl | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 123 insertions(+) > create mode 100644 mappings_to_yaml.pl > >diff --git a/mappings_to_yaml.pl b/mappings_to_yaml.pl >new file mode 100644 >index 0000000..8f3125f >--- /dev/null >+++ b/mappings_to_yaml.pl >@@ -0,0 +1,123 @@ >+use Modern::Perl; >+use YAML::XS; >+ >+my $filename = '/tmp/mapping_es.text'; >+# The format of this file is: >+# ('authorities','Meeting-name-see-also-from',FALSE,FALSE,'','511acdefghjklnpqstvxyz',NULL,'511acdefghjklnpqstvxyz'); >+my $indexes; >+open my $fh, '<', $filename or die "no file"; >+while ( my $line = <$fh> ) { >+ chomp $line; >+ next unless $line; >+ if ( $line =~ m|\('(\w+)','([^']*)','?(\w+)'?,'?([^']*)'?,'?([^']*)'?,'?([^']*)'?,'?([^']*)'?,'?([^']*)'?\);| ) { >+ my $indexname = $1; >+ my $mapping = $2; >+ my $facet = $3 eq 'TRUE'; >+ my $suggestible = $4 eq 'TRUE'; >+ my $type = $5; >+ my $marc21 = $6; >+ my $unimarc = $7; >+ my $normarc = $8; >+ $indexes->{$indexname}{$mapping}{type} = $type; >+ $indexes->{$indexname}{$mapping}{label} = $mapping; >+ for my $marc_type ( qw( marc21 unimarc normarc ) ) { >+ my $marc_field = ${eval('\$' . $marc_type)}; >+ next if not $marc_field or $marc_field eq 'NULL'; >+ push @{ $indexes->{$indexname}{$mapping}{mappings}}, { >+ facet => $facet, >+ suggestible => $suggestible, >+ sort => undef, >+ marc_field => $marc_field, >+ marc_type => $marc_type, >+ } >+ } >+ } >+} >+ >+# Additional rows >+#('biblios','author',TRUE,TRUE,FALSE,'string','700a','700a','700a'); -- no sorting on the >+#('biblios','author',FALSE,FALSE,FALSE,'string','245c','701','245c'); -- extra author fields >+#('biblios','notforloan',FALSE,FALSE,'number','9527','995o','9527'); -- newly created >+ >+push @{$indexes->{biblios}{author}{mappings}}, { >+ facet => 1, >+ suggestible => 1, >+ sort => 0, >+ marc_type => 'marc21', >+ marc_field => => '700a', >+}; >+push @{$indexes->{biblios}{author}{mappings}}, { >+ facet => 1, >+ suggestible => 1, >+ sort => 0, >+ marc_type => 'unimarc', >+ marc_field => => '700a', >+}; >+push @{$indexes->{biblios}{author}{mappings}}, { >+ facet => 1, >+ suggestible => 1, >+ sort => 0, >+ marc_type => 'normarc', >+ marc_field => => '700a', >+}; >+ >+push @{$indexes->{biblios}{author}{mappings}}, { >+ facet => 0, >+ suggestible => 0, >+ sort => 0, >+ marc_type => 'marc21', >+ marc_field => '245c', >+}; >+push @{$indexes->{biblios}{author}{mappings}}, { >+ facet => 0, >+ suggestible => 0, >+ sort => 0, >+ marc_type => 'unimarc', >+ marc_field => '701', >+}; >+push @{$indexes->{biblios}{author}{mappings}}, { >+ facet => 0, >+ suggestible => 0, >+ sort => 0, >+ marc_type => 'normarc', >+ marc_field => '245c', >+}; >+ >+$indexes->{biblios}{notforloan}{type} = 'number'; >+$indexes->{biblios}{notforloan}{label} = 'notforloan'; >+push @{$indexes->{biblios}{notforloan}{mappings}}, { >+ facet => 0, >+ suggestible => 0, >+ sort => undef, >+ marc_type => 'marc21', >+ marc_field => '9527', >+}; >+push @{$indexes->{biblios}{notforloan}{mappings}}, { >+ facet => 0, >+ suggestible => 0, >+ sort => undef, >+ marc_type => 'unimarc', >+ marc_field => '995o', >+}; >+push @{$indexes->{biblios}{notforloan}{mappings}}, { >+ facet => 0, >+ suggestible => 0, >+ sort => undef, >+ marc_type => 'normarc', >+ marc_field => '9527', >+}; >+ >+# Resort to group by marc_type >+while ( my ( $index_name, $fields ) = each %$indexes ) { >+ while ( my ( $field_name, $data ) = each %$fields ) { >+ $indexes->{$index_name}{$field_name}{mappings} = [ >+ sort { $a->{marc_type} cmp $b->{marc_type} || $a->{marc_field} cmp $b->{marc_field} } @{ $indexes->{$index_name}{$field_name}{mappings} } >+ ]; >+ } >+} >+ >+my $yaml = Dump $indexes;; >+ >+open $fh, '>', '/tmp/elastic_search_mappings.yaml'; >+print $fh $yaml; >+close $fh; >-- >2.1.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 12478
:
29204
|
31128
|
31129
|
33136
|
33137
|
33138
|
33139
|
33140
|
33141
|
35654
|
40903
|
42030
|
42031
|
42032
|
42033
|
42062
|
42063
|
42064
|
42065
|
42066
|
42067
|
42068
|
42069
|
42392
|
42393
|
43127
|
43128
|
43129
|
43130
|
43131
|
43132
|
43133
|
43134
|
43140
|
43141
|
43142
|
43148
|
43345
|
43346
|
43347
|
43348
|
43349
|
43350
|
43351
|
43352
|
43373
|
47767
|
47768
|
50115
|
50159
|
50211
|
50212
|
50213
|
50214
|
50245
|
50246
|
50291
|
50292