Bugzilla – Attachment 77008 Details for
Bug 19482
Elasticsearch - prevent removal / editing of required indexes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19482 - Add support for defining 'mandatory' mappings
Bug-19482---Add-support-for-defining-mandatory-map.patch (text/plain), 13.17 KB, created by
Nick Clemens (kidclamp)
on 2018-07-16 15:54:41 UTC
(
hide
)
Description:
Bug 19482 - Add support for defining 'mandatory' mappings
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-07-16 15:54:41 UTC
Size:
13.17 KB
patch
obsolete
>From bc78a482d363d2bb169db53003a926fc5e3abae5 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 18 Oct 2017 13:06:22 +0000 >Subject: [PATCH] Bug 19482 - Add support for defining 'mandatory' mappings > >To test: >1 - Apply patch >2 - ./installer/data/mysql/updatedatabase.pl >3 - Clear all ES mappings form the db: DELETE FROM search_field; >DELETE FROM search_marc_map; DELETE FROM search_marc_to_field; >4 - Reset ES mapping: >/cgi-bin/koha/admin/searchengine/elasticsearch/mappings.pl?op=reset&i_know_what_i_am_doing=1 >5 - issues should now be uneditable and not removable > >Signed-off-by: Nicolas Legrand <nicolas.legrand@bulac.fr> >--- > Koha/SearchEngine/Elasticsearch.pm | 4 +- > admin/searchengine/elasticsearch/mappings.pl | 1 + > admin/searchengine/elasticsearch/mappings.yaml | 1 + > .../admin/searchengine/elasticsearch/mappings.tt | 136 +++++++++++++-------- > 4 files changed, 88 insertions(+), 54 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm >index 9c114fb..bc129f6 100644 >--- a/Koha/SearchEngine/Elasticsearch.pm >+++ b/Koha/SearchEngine/Elasticsearch.pm >@@ -255,8 +255,10 @@ sub reset_elasticsearch_mappings { > while ( my ( $field_name, $data ) = each %$fields ) { > my $field_type = $data->{type}; > my $field_label = $data->{label}; >+ my $field_mandatory = $data->{mandatory}; >+ warn $field_mandatory; > my $mappings = $data->{mappings}; >- my $search_field = Koha::SearchFields->find_or_create({ name => $field_name, label => $field_label, type => $field_type }, { key => 'name' }); >+ my $search_field = Koha::SearchFields->find_or_create({ name => $field_name, label => $field_label, type => $field_type, mandatory => $field_mandatory }, { key => 'name' }); > for my $mapping ( @$mappings ) { > my $marc_field = Koha::SearchMarcMaps->find_or_create({ index_name => $index_name, marc_type => $mapping->{marc_type}, marc_field => $mapping->{marc_field} }); > $search_field->add_to_search_marc_maps($marc_field, { facet => $mapping->{facet} || 0, suggestible => $mapping->{suggestible} || 0, sort => $mapping->{sort} } ); >diff --git a/admin/searchengine/elasticsearch/mappings.pl b/admin/searchengine/elasticsearch/mappings.pl >index 7d63002..3124a7f 100755 >--- a/admin/searchengine/elasticsearch/mappings.pl >+++ b/admin/searchengine/elasticsearch/mappings.pl >@@ -123,6 +123,7 @@ for my $index_name (qw| biblios authorities |) { > { search_field_name => $s->name, > search_field_label => $s->label, > search_field_type => $s->type, >+ search_field_mandatory => $s->mandatory, > marc_field => $s->get_column('marc_field'), > sort => $s->get_column('sort') // 'undef', # To avoid warnings "Use of uninitialized value in lc" > suggestible => $s->get_column('suggestible'), >diff --git a/admin/searchengine/elasticsearch/mappings.yaml b/admin/searchengine/elasticsearch/mappings.yaml >index 18e63fa..a5aef26 100644 >--- a/admin/searchengine/elasticsearch/mappings.yaml >+++ b/admin/searchengine/elasticsearch/mappings.yaml >@@ -2216,6 +2216,7 @@ biblios: > sort: 1 > suggestible: '' > type: sum >+ mandatory: 1 > itemnumber: > label: itemnumber > mappings: >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt >index 1cb3c41..f38ffe5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt >@@ -131,12 +131,20 @@ a.add, a.delete { > </thead> > <tbody> > [% FOREACH search_field IN all_search_fields %] >+ [% IF search_field.mandatory %] >+ [% SET is_readonly = "readonly" %] >+ [% ELSE %] >+ [% SET is_readonly = "" %] >+ [% END %] > <tr> > <td> >- <input type="text" name="search_field_name" value="[% search_field.name %]" /> >+ <input type="text" name="search_field_name" value="[% search_field.name %]" [% is_readonly %]/> > </td> >- <td><input type="text" name="search_field_label" value="[% search_field.label %]" /> >+ <td><input type="text" name="search_field_label" value="[% search_field.label %]" [% is_readonly %]/> > <td> >+ [% IF is_readonly %] >+ <input type="text" name="search_field_type" value="[% search_field.type FILTER ucfirst%]" [% is_readonly %] /> >+ [% ELSE %] > <select name="search_field_type"> > <option value=""></option> > [% IF search_field.type == "string" %] >@@ -196,59 +204,81 @@ a.add, a.delete { > </thead> > <tbody> > [% FOREACH mapping IN index.mappings %] >- <tr> >- <td> >- <input type="hidden" name="mapping_index_name" value="[% index.index_name %]" /> >- <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name %]"> >+ [% IF mapping.search_field_mandatory %] >+ <tr> >+ <td> >+ <input type="hidden" name="mapping_index_name" value="[% index.index_name %]" /> >+ <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name %]"> > [% mapping.search_field_label %] >- </td> >- <td> >- <select name="mapping_sort"> >- [% IF mapping.sort == 'undef' %] >- <option value="undef" selected="selected">Undef</option> >- [% ELSE %] >- <option value="undef">Undef</option> >- [% END %] >- [% IF mapping.sort == 0 %] >- <option value="0" selected="selected">0</option> >- [% ELSE %] >- <option value="0">0</option> >- [% END %] >- [% IF mapping.sort == 1 %] >- <option value="1" selected="selected">1</option> >- [% ELSE %] >- <option value="1">1</option> >- [% END %] >- </select> >- </td> >- <td> >- <select name="mapping_facet"> >- [% IF mapping.facet %] >- <option value="0">No</option> >- <option value="1" selected="selected">Yes</option> >- [% ELSE %] >- <option value="0" selected="selected">No</option> >- <option value="1">Yes</option> >- [% END %] >- </select> >- </td> >- <td> >- <select name="mapping_suggestible"> >- [% IF mapping.suggestible %] >- <option value="0">No</option> >- <option value="1" selected="selected">Yes</option> >- [% ELSE %] >- <option value="0" selected="selected">No</option> >- <option value="1">Yes</option> >+ </td> >+ <td> >+ <input type="hidden" name="mapping_sort" value="[% mapping.sort %]" readonly />[% IF mapping.sort == 'undef' %]Undef[% ELSE %][% mapping.sort %][% END %] >+ </td> >+ <td> >+ <input type="hidden" name="mapping_facet" value="[% mapping.facet %]" readonly />[% IF mapping.facet == 1 %]Yes[% ELSE %]No[% END %] >+ </td> >+ <td> >+ <input type="hidden" name="mapping_suggestible" value="[% mapping.suggestible %]" readonly />[% IF mapping.suggestible == 1 %]Yes[% ELSE %]No[% END %] >+ </td> >+ <td> >+ <input type="text" name="mapping_marc_field" value="[% mapping.marc_field %]" readonly /> >+ </td> >+ </tr> >+ [% ELSE %] >+ <tr> >+ <td> >+ <input type="hidden" name="mapping_index_name" value="[% index.index_name %]" /> >+ <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name %]"> >+ [% mapping.search_field_label %] >+ </td> >+ <td> >+ <select name="mapping_sort"> >+ [% IF mapping.sort == 'undef' %] >+ <option value="undef" selected="selected">Undef</option> >+ [% ELSE %] >+ <option value="undef">Undef</option> >+ [% END %] >+ [% IF mapping.sort == 0 %] >+ <option value="0" selected="selected">0</option> >+ [% ELSE %] >+ <option value="0">0</option> >+ [% END %] >+ [% IF mapping.sort == 1 %] >+ <option value="1" selected="selected">1</option> >+ [% ELSE %] >+ <option value="1">1</option> >+ [% END %] >+ </select> >+ </td> >+ <td> >+ <select name="mapping_facet"> >+ [% IF mapping.facet %] >+ <option value="0">No</option> >+ <option value="1" selected="selected">Yes</option> >+ [% ELSE %] >+ <option value="0" selected="selected">No</option> >+ <option value="1">Yes</option> >+ [% END %] >+ </select> >+ </td> >+ <td> >+ <select name="mapping_suggestible"> >+ [% IF mapping.suggestible %] >+ <option value="0">No</option> >+ <option value="1" selected="selected">Yes</option> >+ [% ELSE %] >+ <option value="0" selected="selected">No</option> >+ <option value="1">Yes</option> >+ [% END %] >+ </select> >+ </td> >+ <td> >+ <input name="mapping_marc_field" type="text" value="[% mapping.marc_field %]" /> >+ </td> >+ <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td> >+ </tr> > [% END %] >- </select> >- </td> >- <td> >- <input name="mapping_marc_field" type="text" value="[% mapping.marc_field %]" /> >- </td> >- <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td> >- </tr> >- [% END %] >+ [% END %] > </tbody> > <tfoot> > <tr class="nodrag nodrop"> >-- >2.1.4
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 19482
:
68246
|
68247
|
68248
|
69250
|
72846
|
72847
|
72848
|
72878
|
72879
|
72880
|
77007
|
77008
|
77009
|
77010
|
80817
|
80818
|
80819
|
80820
|
93366
|
93367
|
93368
|
93371
|
93372
|
93373
|
97226
|
97227
|
97228
|
101312
|
101313
|
101314
|
108467
|
108468
|
108469
|
108470
|
108471
|
111923
|
111924
|
111925
|
111926
|
111927
|
111929
|
112456
|
112459
|
112460
|
112461
|
112462
|
112463
|
112464
|
112465