Bugzilla – Attachment 80818 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.56 KB, created by
Nick Clemens (kidclamp)
on 2018-10-18 12:25:36 UTC
(
hide
)
Description:
Bug 19482 - Add support for defining 'mandatory' mappings
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-10-18 12:25:36 UTC
Size:
13.56 KB
patch
obsolete
>From 06b038d25fad3456be32910844217c225f4d6924 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 | 139 +++++++++++++-------- > 4 files changed, 89 insertions(+), 56 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 ecd8741..9cd3e90 100755 >--- a/admin/searchengine/elasticsearch/mappings.pl >+++ b/admin/searchengine/elasticsearch/mappings.pl >@@ -126,6 +126,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 cc7b28c..40ec383 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 >@@ -145,12 +145,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 | html %]" /> >+ <input type="text" name="search_field_name" value="[% search_field.name | html %]" [% is_readonly %]/> > </td> >- <td><input type="text" name="search_field_label" value="[% search_field.label | html %]" /> >+ <td><input type="text" name="search_field_label" value="[% search_field.label | html %]" [% is_readonly %]/> > <td> >+ [% IF is_readonly %] >+ <input type="text" name="search_field_type" value="[% search_field.type FILTER ucfirst | html %]" [% is_readonly %] /> >+ [% ELSE %] > <select name="search_field_type"> > <option value=""></option> > [% IF search_field.type == "string" %] >@@ -210,59 +218,80 @@ a.add, a.delete { > </thead> > <tbody> > [% FOREACH mapping IN index.mappings %] >- <tr> >- <td> >- <input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" /> >- <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]"> >- [% mapping.search_field_label | html %] >- </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 | html %]" /> >- </td> >- <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td> >- </tr> >- [% END %] >+ [% IF mapping.search_field_mandatory %] >+ <tr> >+ <td> >+ <input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" /> >+ <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]"> >+ [% mapping.search_field_label %] >+ </td> >+ <td> >+ <input type="hidden" name="mapping_sort" value="[% mapping.sort | html %]" readonly />[% IF mapping.sort == 'undef' %]Undef[% ELSE %][% mapping.sort | html %][% END %] >+ </td> >+ <td> >+ <input type="hidden" name="mapping_facet" value="[% mapping.facet | html %]" readonly />[% IF mapping.facet == 1 %]Yes[% ELSE %]No[% END %] >+ </td> >+ <td> >+ <input type="hidden" name="mapping_suggestible" value="[% mapping.suggestible | html %]" readonly />[% IF mapping.suggestible == 1 %]Yes[% ELSE %]No[% END %] >+ </td> >+ <td> >+ <input type="text" name="mapping_marc_field" value="[% mapping.marc_field | html %]" readonly /> >+ </td> >+ </tr> >+ [% ELSE %] >+ <tr> >+ <td> >+ <input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" /> >+ <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]"> >+ [% mapping.search_field_label | html %] >+ </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 | html %]" /> >+ </td> >+ <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td> >+ </tr> >+ [% 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