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 126-131 for my $index_name (qw| biblios authorities |) { Link Here
126
          { search_field_name  => $s->name,
126
          { search_field_name  => $s->name,
127
            search_field_label => $s->label,
127
            search_field_label => $s->label,
128
            search_field_type  => $s->type,
128
            search_field_type  => $s->type,
129
            search_field_mandatory  => $s->mandatory,
129
            marc_field         => $s->get_column('marc_field'),
130
            marc_field         => $s->get_column('marc_field'),
130
            sort               => $s->get_column('sort') // 'undef', # To avoid warnings "Use of uninitialized value in lc"
131
            sort               => $s->get_column('sort') // 'undef', # To avoid warnings "Use of uninitialized value in lc"
131
            suggestible        => $s->get_column('suggestible'),
132
            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 (-56 / +84 lines)
Lines 145-156 a.add, a.delete { Link Here
145
                </thead>
145
                </thead>
146
                <tbody>
146
                <tbody>
147
                  [% FOREACH search_field IN all_search_fields %]
147
                  [% FOREACH search_field IN all_search_fields %]
148
                      [% IF search_field.mandatory %]
149
                          [% SET is_readonly = "readonly" %]
150
                      [% ELSE %]
151
                          [% SET is_readonly = "" %]
152
                      [% END %]
148
                    <tr>
153
                    <tr>
149
                      <td>
154
                      <td>
150
                        <input type="text" name="search_field_name" value="[% search_field.name | html %]" />
155
                        <input type="text" name="search_field_name" value="[% search_field.name | html %]" [% is_readonly %]/>
151
                      </td>
156
                      </td>
152
                      <td><input type="text" name="search_field_label" value="[% search_field.label | html %]" />
157
                      <td><input type="text" name="search_field_label" value="[% search_field.label | html %]" [% is_readonly %]/>
153
                      <td>
158
                      <td>
159
                        [% IF is_readonly %]
160
                            <input type="text" name="search_field_type" value="[% search_field.type FILTER ucfirst | html %]" [% is_readonly %] />
161
                        [% ELSE %]
154
                        <select name="search_field_type">
162
                        <select name="search_field_type">
155
                          <option value=""></option>
163
                          <option value=""></option>
156
                          [% IF search_field.type == "string" %]
164
                          [% IF search_field.type == "string" %]
Lines 210-268 a.add, a.delete { Link Here
210
                      </thead>
218
                      </thead>
211
                      <tbody>
219
                      <tbody>
212
                        [% FOREACH mapping IN index.mappings %]
220
                        [% FOREACH mapping IN index.mappings %]
213
                          <tr>
221
                            [% IF mapping.search_field_mandatory %]
214
                            <td>
222
                                <tr>
215
                              <input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" />
223
                                    <td>
216
                              <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]">
224
                                        <input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" />
217
                              [% mapping.search_field_label | html %]
225
                                        <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]">
218
                            </td>
226
                                        [% mapping.search_field_label %]
219
                            <td>
227
                                    </td>
220
                              <select name="mapping_sort">
228
                                    <td>
221
                                [% IF mapping.sort == 'undef' %]
229
                                        <input type="hidden" name="mapping_sort" value="[% mapping.sort | html %]" readonly />[% IF mapping.sort == 'undef' %]Undef[% ELSE %][% mapping.sort | html %][% END %]
222
                                  <option value="undef" selected="selected">Undef</option>
230
                                    </td>
223
                                [% ELSE %]
231
                                    <td>
224
                                  <option value="undef">Undef</option>
232
                                        <input type="hidden" name="mapping_facet" value="[% mapping.facet | html %]" readonly />[% IF mapping.facet == 1 %]Yes[% ELSE %]No[% END %]
225
                                [% END %]
233
                                    </td>
226
                                [% IF mapping.sort == 0 %]
234
                                    <td>
227
                                  <option value="0" selected="selected">0</option>
235
                                        <input type="hidden" name="mapping_suggestible" value="[% mapping.suggestible | html %]" readonly />[% IF mapping.suggestible == 1 %]Yes[% ELSE %]No[% END %]
228
                                [% ELSE %]
236
                                    </td>
229
                                  <option value="0">0</option>
237
                                    <td>
230
                                [% END %]
238
                                        <input type="text" name="mapping_marc_field" value="[% mapping.marc_field | html %]" readonly />
231
                                [% IF  mapping.sort == 1 %]
239
                                    </td>
232
                                  <option value="1" selected="selected">1</option>
240
                                </tr>
233
                                [% ELSE %]
241
                            [% ELSE %]
234
                                  <option value="1">1</option>
242
                                <tr>
235
                                [% END %]
243
                                  <td>
236
                              </select>
244
                                      <input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" />
237
                            </td>
245
                                      <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]">
238
                            <td>
246
                                      [% mapping.search_field_label | html %]
239
                              <select name="mapping_facet">
247
                                  </td>
240
                                [% IF mapping.facet %]
248
                                  <td>
241
                                  <option value="0">No</option>
249
                                      <select name="mapping_sort">
242
                                  <option value="1" selected="selected">Yes</option>
250
                                        [% IF mapping.sort == 'undef' %]
243
                                [% ELSE %]
251
                                          <option value="undef" selected="selected">Undef</option>
244
                                  <option value="0" selected="selected">No</option>
252
                                        [% ELSE %]
245
                                  <option value="1">Yes</option>
253
                                          <option value="undef">Undef</option>
246
                                [% END %]
254
                                        [% END %]
247
                              </select>
255
                                        [% IF mapping.sort == 0 %]
248
                            </td>
256
                                          <option value="0" selected="selected">0</option>
249
                            <td>
257
                                        [% ELSE %]
250
                              <select name="mapping_suggestible">
258
                                          <option value="0">0</option>
251
                                [% IF mapping.suggestible %]
259
                                        [% END %]
252
                                  <option value="0">No</option>
260
                                        [% IF  mapping.sort == 1 %]
253
                                  <option value="1" selected="selected">Yes</option>
261
                                          <option value="1" selected="selected">1</option>
254
                                [% ELSE %]
262
                                        [% ELSE %]
255
                                  <option value="0" selected="selected">No</option>
263
                                          <option value="1">1</option>
256
                                  <option value="1">Yes</option>
264
                                        [% END %]
257
                                [% END %]
265
                                      </select>
258
                              </select>
266
                                  </td>
259
                            </td>
267
                                  <td>
260
                            <td>
268
                                      <select name="mapping_facet">
261
                                <input name="mapping_marc_field" type="text" value="[% mapping.marc_field | html %]" />
269
                                        [% IF mapping.facet %]
262
                            </td>
270
                                          <option value="0">No</option>
263
                            <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td>
271
                                          <option value="1" selected="selected">Yes</option>
264
                          </tr>
272
                                        [% ELSE %]
265
                        [% END %]
273
                                          <option value="0" selected="selected">No</option>
274
                                          <option value="1">Yes</option>
275
                                        [% END %]
276
                                      </select>
277
                                  </td>
278
                                  <td>
279
                                      <select name="mapping_suggestible">
280
                                        [% IF mapping.suggestible %]
281
                                          <option value="0">No</option>
282
                                          <option value="1" selected="selected">Yes</option>
283
                                        [% ELSE %]
284
                                          <option value="0" selected="selected">No</option>
285
                                          <option value="1">Yes</option>
286
                                        [% END %]
287
                                      </select>
288
                                  </td>
289
                                  <td>
290
                                      <input name="mapping_marc_field" type="text" value="[% mapping.marc_field | html %]" />
291
                                  </td>
292
                                  <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td>
293
                              </tr>
294
                            [% END %]
266
                      </tbody>
295
                      </tbody>
267
                      <tfoot>
296
                      <tfoot>
268
                        <tr class="nodrag nodrop">
297
                        <tr class="nodrag nodrop">
269
- 

Return to bug 19482