@@ -, +, @@ --- Koha/SearchEngine/Elasticsearch.pm | 4 +- admin/searchengine/elasticsearch/mappings.pl | 1 + admin/searchengine/elasticsearch/mappings.yaml | 1 + .../admin/searchengine/elasticsearch/mappings.tt | 193 ++++++++++++--------- 4 files changed, 117 insertions(+), 82 deletions(-) --- a/Koha/SearchEngine/Elasticsearch.pm +++ a/Koha/SearchEngine/Elasticsearch.pm @@ -282,8 +282,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} } ); --- a/admin/searchengine/elasticsearch/mappings.pl +++ a/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'), --- a/admin/searchengine/elasticsearch/mappings.yaml +++ a/admin/searchengine/elasticsearch/mappings.yaml @@ -1602,6 +1602,7 @@ biblios: sort: 1 suggestible: '' type: sum + mandatory: 1 itemnumber: label: itemnumber mappings: --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt @@ -130,40 +130,49 @@ a.add, a.delete { [% FOREACH search_field IN all_search_fields %] + [% IF search_field.mandatory %] + [% SET is_readonly = "readonly" %] + [% ELSE %] + [% SET is_readonly = "" %] + [% END %] - + - + - + [% IF is_readonly %] + + [% ELSE %] + + [% END %] [% END %] @@ -185,59 +194,81 @@ a.add, a.delete { [% FOREACH mapping IN index.mappings %] - - - - + [% IF mapping.search_field_mandatory %] + + + + [% mapping.search_field_label %] - - - - - - - - - [% IF mapping.sort == 'undef' %]Undef[% ELSE %][% mapping.sort %][% END %] + + + [% IF mapping.facet == 1 %]Yes[% ELSE %]No[% END %] + + + [% IF mapping.suggestible == 1 %]Yes[% ELSE %]No[% END %] + + + + + + [% ELSE %] + + + + + [% mapping.search_field_label %] + + + + + + + + + + + + + + Delete + [% END %] - - - - - - Delete - - [% END %] + [% END %] --