View | Details | Raw Unified | Return to bug 19482
Collapse All | Expand All

(-)a/Koha/SearchEngine/Elasticsearch.pm (-1 / +3 lines)
Lines 255-262 sub reset_elasticsearch_mappings { Link Here
255
        while ( my ( $field_name, $data ) = each %$fields ) {
255
        while ( my ( $field_name, $data ) = each %$fields ) {
256
            my $field_type = $data->{type};
256
            my $field_type = $data->{type};
257
            my $field_label = $data->{label};
257
            my $field_label = $data->{label};
258
            my $field_mandatory = $data->{mandatory};
259
            warn $field_mandatory;
258
            my $mappings = $data->{mappings};
260
            my $mappings = $data->{mappings};
259
            my $search_field = Koha::SearchFields->find_or_create({ name => $field_name, label => $field_label, type => $field_type }, { key => 'name' });
261
            my $search_field = Koha::SearchFields->find_or_create({ name => $field_name, label => $field_label, type => $field_type, mandatory => $field_mandatory }, { key => 'name' });
260
            for my $mapping ( @$mappings ) {
262
            for my $mapping ( @$mappings ) {
261
                my $marc_field = Koha::SearchMarcMaps->find_or_create({ index_name => $index_name, marc_type => $mapping->{marc_type}, marc_field => $mapping->{marc_field} });
263
                my $marc_field = Koha::SearchMarcMaps->find_or_create({ index_name => $index_name, marc_type => $mapping->{marc_type}, marc_field => $mapping->{marc_field} });
262
                $search_field->add_to_search_marc_maps($marc_field, { facet => $mapping->{facet} || 0, suggestible => $mapping->{suggestible} || 0, sort => $mapping->{sort} } );
264
                $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 (+1 lines)
Lines 123-128 for my $index_name (qw| biblios authorities |) { Link Here
123
          { search_field_name  => $s->name,
123
          { search_field_name  => $s->name,
124
            search_field_label => $s->label,
124
            search_field_label => $s->label,
125
            search_field_type  => $s->type,
125
            search_field_type  => $s->type,
126
            search_field_mandatory  => $s->mandatory,
126
            marc_field         => $s->get_column('marc_field'),
127
            marc_field         => $s->get_column('marc_field'),
127
            sort               => $s->get_column('sort') // 'undef', # To avoid warnings "Use of uninitialized value in lc"
128
            sort               => $s->get_column('sort') // 'undef', # To avoid warnings "Use of uninitialized value in lc"
128
            suggestible        => $s->get_column('suggestible'),
129
            suggestible        => $s->get_column('suggestible'),
(-)a/admin/searchengine/elasticsearch/mappings.yaml (+1 lines)
Lines 2216-2221 biblios: Link Here
2216
        sort: 1
2216
        sort: 1
2217
        suggestible: ''
2217
        suggestible: ''
2218
    type: sum
2218
    type: sum
2219
    mandatory: 1
2219
  itemnumber:
2220
  itemnumber:
2220
    label: itemnumber
2221
    label: itemnumber
2221
    mappings:
2222
    mappings:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt (-54 / +83 lines)
Lines 131-142 a.add, a.delete { Link Here
131
                </thead>
131
                </thead>
132
                <tbody>
132
                <tbody>
133
                  [% FOREACH search_field IN all_search_fields %]
133
                  [% FOREACH search_field IN all_search_fields %]
134
                      [% IF search_field.mandatory %]
135
                          [% SET is_readonly = "readonly" %]
136
                      [% ELSE %]
137
                          [% SET is_readonly = "" %]
138
                      [% END %]
134
                    <tr>
139
                    <tr>
135
                      <td>
140
                      <td>
136
                        <input type="text" name="search_field_name" value="[% search_field.name %]" />
141
                        <input type="text" name="search_field_name" value="[% search_field.name %]" [% is_readonly %]/>
137
                      </td>
142
                      </td>
138
                      <td><input type="text" name="search_field_label" value="[% search_field.label %]" />
143
                      <td><input type="text" name="search_field_label" value="[% search_field.label %]" [% is_readonly %]/>
139
                      <td>
144
                      <td>
145
                        [% IF is_readonly %]
146
                            <input type="text" name="search_field_type" value="[% search_field.type FILTER ucfirst%]" [% is_readonly %] />
147
                        [% ELSE %]
140
                        <select name="search_field_type">
148
                        <select name="search_field_type">
141
                          <option value=""></option>
149
                          <option value=""></option>
142
                          [% IF search_field.type == "string" %]
150
                          [% IF search_field.type == "string" %]
Lines 196-254 a.add, a.delete { Link Here
196
                      </thead>
204
                      </thead>
197
                      <tbody>
205
                      <tbody>
198
                        [% FOREACH mapping IN index.mappings %]
206
                        [% FOREACH mapping IN index.mappings %]
199
                          <tr>
207
                            [% IF mapping.search_field_mandatory %]
200
                            <td>
208
                                <tr>
201
                              <input type="hidden" name="mapping_index_name" value="[% index.index_name %]" />
209
                                    <td>
202
                              <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name %]">
210
                                        <input type="hidden" name="mapping_index_name" value="[% index.index_name %]" />
211
                                        <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name %]">
203
                              [% mapping.search_field_label %]
212
                              [% mapping.search_field_label %]
204
                            </td>
213
                                    </td>
205
                            <td>
214
                                    <td>
206
                              <select name="mapping_sort">
215
                                        <input type="hidden" name="mapping_sort" value="[% mapping.sort %]" readonly />[% IF mapping.sort == 'undef' %]Undef[% ELSE %][% mapping.sort %][% END %]
207
                                [% IF mapping.sort == 'undef' %]
216
                                    </td>
208
                                  <option value="undef" selected="selected">Undef</option>
217
                                    <td>
209
                                [% ELSE %]
218
                                        <input type="hidden" name="mapping_facet" value="[% mapping.facet %]" readonly />[% IF mapping.facet == 1 %]Yes[% ELSE %]No[% END %]
210
                                  <option value="undef">Undef</option>
219
                                    </td>
211
                                [% END %]
220
                                    <td>
212
                                [% IF mapping.sort == 0 %]
221
                                        <input type="hidden" name="mapping_suggestible" value="[% mapping.suggestible %]" readonly />[% IF mapping.suggestible == 1 %]Yes[% ELSE %]No[% END %]
213
                                  <option value="0" selected="selected">0</option>
222
                                    </td>
214
                                [% ELSE %]
223
                                    <td>
215
                                  <option value="0">0</option>
224
                                        <input type="text" name="mapping_marc_field" value="[% mapping.marc_field %]" readonly />
216
                                [% END %]
225
                                    </td>
217
                                [% IF  mapping.sort == 1 %]
226
                                </tr>
218
                                  <option value="1" selected="selected">1</option>
227
                            [% ELSE %]
219
                                [% ELSE %]
228
                              <tr>
220
                                  <option value="1">1</option>
229
                                <td>
221
                                [% END %]
230
                                  <input type="hidden" name="mapping_index_name" value="[% index.index_name %]" />
222
                              </select>
231
                                  <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name %]">
223
                            </td>
232
                              [% mapping.search_field_label %]
224
                            <td>
233
                                </td>
225
                              <select name="mapping_facet">
234
                                <td>
226
                                [% IF mapping.facet %]
235
                                  <select name="mapping_sort">
227
                                  <option value="0">No</option>
236
                                    [% IF mapping.sort == 'undef' %]
228
                                  <option value="1" selected="selected">Yes</option>
237
                                      <option value="undef" selected="selected">Undef</option>
229
                                [% ELSE %]
238
                                    [% ELSE %]
230
                                  <option value="0" selected="selected">No</option>
239
                                      <option value="undef">Undef</option>
231
                                  <option value="1">Yes</option>
240
                                    [% END %]
232
                                [% END %]
241
                                    [% IF mapping.sort == 0 %]
233
                              </select>
242
                                      <option value="0" selected="selected">0</option>
234
                            </td>
243
                                    [% ELSE %]
235
                            <td>
244
                                      <option value="0">0</option>
236
                              <select name="mapping_suggestible">
245
                                    [% END %]
237
                                [% IF mapping.suggestible %]
246
                                    [% IF  mapping.sort == 1 %]
238
                                  <option value="0">No</option>
247
                                      <option value="1" selected="selected">1</option>
239
                                  <option value="1" selected="selected">Yes</option>
248
                                    [% ELSE %]
240
                                [% ELSE %]
249
                                      <option value="1">1</option>
241
                                  <option value="0" selected="selected">No</option>
250
                                    [% END %]
242
                                  <option value="1">Yes</option>
251
                                  </select>
252
                                </td>
253
                                <td>
254
                                  <select name="mapping_facet">
255
                                    [% IF mapping.facet %]
256
                                      <option value="0">No</option>
257
                                      <option value="1" selected="selected">Yes</option>
258
                                    [% ELSE %]
259
                                      <option value="0" selected="selected">No</option>
260
                                      <option value="1">Yes</option>
261
                                    [% END %]
262
                                  </select>
263
                                </td>
264
                                <td>
265
                                  <select name="mapping_suggestible">
266
                                    [% IF mapping.suggestible %]
267
                                      <option value="0">No</option>
268
                                      <option value="1" selected="selected">Yes</option>
269
                                    [% ELSE %]
270
                                      <option value="0" selected="selected">No</option>
271
                                      <option value="1">Yes</option>
272
                                    [% END %]
273
                                  </select>
274
                                </td>
275
                                <td>
276
                                    <input name="mapping_marc_field" type="text" value="[% mapping.marc_field %]" />
277
                                </td>
278
                                <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td>
279
                              </tr>
243
                                [% END %]
280
                                [% END %]
244
                              </select>
281
                            [% END %]
245
                            </td>
246
                            <td>
247
                                <input name="mapping_marc_field" type="text" value="[% mapping.marc_field %]" />
248
                            </td>
249
                            <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td>
250
                          </tr>
251
                        [% END %]
252
                      </tbody>
282
                      </tbody>
253
                      <tfoot>
283
                      <tfoot>
254
                        <tr class="nodrag nodrop">
284
                        <tr class="nodrag nodrop">
255
- 

Return to bug 19482