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

(-)a/Koha/SearchEngine/Elasticsearch.pm (-1 / +3 lines)
Lines 286-293 sub reset_elasticsearch_mappings { Link Here
286
        while ( my ( $field_name, $data ) = each %$fields ) {
286
        while ( my ( $field_name, $data ) = each %$fields ) {
287
            my $field_type = $data->{type};
287
            my $field_type = $data->{type};
288
            my $field_label = $data->{label};
288
            my $field_label = $data->{label};
289
            my $field_mandatory = $data->{mandatory};
290
            warn $field_mandatory;
289
            my $mappings = $data->{mappings};
291
            my $mappings = $data->{mappings};
290
            my $search_field = Koha::SearchFields->find_or_create({ name => $field_name, label => $field_label, type => $field_type }, { key => 'name' });
292
            my $search_field = Koha::SearchFields->find_or_create({ name => $field_name, label => $field_label, type => $field_type, mandatory => $field_mandatory }, { key => 'name' });
291
            for my $mapping ( @$mappings ) {
293
            for my $mapping ( @$mappings ) {
292
                my $marc_field = Koha::SearchMarcMaps->find_or_create({ index_name => $index_name, marc_type => $mapping->{marc_type}, marc_field => $mapping->{marc_field} });
294
                my $marc_field = Koha::SearchMarcMaps->find_or_create({ index_name => $index_name, marc_type => $mapping->{marc_type}, marc_field => $mapping->{marc_field} });
293
                $search_field->add_to_search_marc_maps($marc_field, { facet => $mapping->{facet} || 0, suggestible => $mapping->{suggestible} || 0, sort => $mapping->{sort} } );
295
                $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 1602-1607 biblios: Link Here
1602
        sort: 1
1602
        sort: 1
1603
        suggestible: ''
1603
        suggestible: ''
1604
    type: sum
1604
    type: sum
1605
    mandatory: 1
1605
  itemnumber:
1606
  itemnumber:
1606
    label: itemnumber
1607
    label: itemnumber
1607
    mappings:
1608
    mappings:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt (-82 / +112 lines)
Lines 130-169 a.add, a.delete { Link Here
130
                </thead>
130
                </thead>
131
                <tbody>
131
                <tbody>
132
                  [% FOREACH search_field IN all_search_fields %]
132
                  [% FOREACH search_field IN all_search_fields %]
133
                      [% IF search_field.mandatory %]
134
                          [% SET is_readonly = "readonly" %]
135
                      [% ELSE %]
136
                          [% SET is_readonly = "" %]
137
                      [% END %]
133
                    <tr>
138
                    <tr>
134
                      <td>
139
                      <td>
135
                        <input type="text" name="search_field_name" value="[% search_field.name %]" />
140
                        <input type="text" name="search_field_name" value="[% search_field.name %]" [% is_readonly %]/>
136
                      </td>
141
                      </td>
137
                      <td><input type="text" name="search_field_label" value="[% search_field.label %]" />
142
                      <td><input type="text" name="search_field_label" value="[% search_field.label %]" [% is_readonly %]/>
138
                      <td>
143
                      <td>
139
                        <select name="search_field_type">
144
                        [% IF is_readonly %]
140
                          <option value=""></option>
145
                            <input type="text" name="search_field_type" value="[% search_field.type FILTER ucfirst%]" [% is_readonly %] />
141
                          [% IF search_field.type == "string" %]
146
                        [% ELSE %]
142
                            <option value="string" selected="selected">String</option>
147
                            <select name="search_field_type">
143
                          [% ELSE %]
148
                              <option value=""></option>
144
                            <option value="string">String</option>
149
                              [% IF search_field.type == "string" %]
145
                          [% END %]
150
                                <option value="string" selected="selected">String</option>
146
                          [% IF search_field.type == "date" %]
151
                              [% ELSE %]
147
                            <option value="date" selected="selected">Date</option>
152
                                <option value="string">String</option>
148
                          [% ELSE %]
153
                              [% END %]
149
                            <option value="date">Date</option>
154
                              [% IF search_field.type == "date" %]
150
                          [% END %]
155
                                <option value="date" selected="selected">Date</option>
151
                          [% IF search_field.type == "number" %]
156
                              [% ELSE %]
152
                            <option value="number" selected="selected">Number</option>
157
                                <option value="date">Date</option>
153
                          [% ELSE %]
158
                              [% END %]
154
                            <option value="number">Number</option>
159
                              [% IF search_field.type == "number" %]
155
                          [% END %]
160
                                <option value="number" selected="selected">Number</option>
156
                          [% IF search_field.type == "boolean" %]
161
                              [% ELSE %]
157
                            <option value="boolean" selected="selected">Boolean</option>
162
                                <option value="number">Number</option>
158
                          [% ELSE %]
163
                              [% END %]
159
                            <option value="boolean">Boolean</option>
164
                              [% IF search_field.type == "boolean" %]
160
                          [% END %]
165
                                <option value="boolean" selected="selected">Boolean</option>
161
                          [% IF search_field.type == "sum" %]
166
                              [% ELSE %]
162
                            <option value="sum" selected="selected">Sum</option>
167
                                <option value="boolean">Boolean</option>
163
                          [% ELSE %]
168
                              [% END %]
164
                            <option value="sum">Sum</option>
169
                              [% IF search_field.type == "sum" %]
165
                          [% END %]
170
                                <option value="sum" selected="selected">Sum</option>
166
                        </select>
171
                              [% ELSE %]
172
                                <option value="sum">Sum</option>
173
                              [% END %]
174
                            </select>
175
                        [% END %]
167
                      </td>
176
                      </td>
168
                    </tr>
177
                    </tr>
169
                  [% END %]
178
                  [% END %]
Lines 185-243 a.add, a.delete { Link Here
185
                      </thead>
194
                      </thead>
186
                      <tbody>
195
                      <tbody>
187
                        [% FOREACH mapping IN index.mappings %]
196
                        [% FOREACH mapping IN index.mappings %]
188
                          <tr>
197
                            [% IF mapping.search_field_mandatory %]
189
                            <td>
198
                                <tr>
190
                              <input type="hidden" name="mapping_index_name" value="[% index.index_name %]" />
199
                                    <td>
191
                              <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name %]">
200
                                        <input type="hidden" name="mapping_index_name" value="[% index.index_name %]" />
201
                                        <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name %]">
192
                              [% mapping.search_field_label %]
202
                              [% mapping.search_field_label %]
193
                            </td>
203
                                    </td>
194
                            <td>
204
                                    <td>
195
                              <select name="mapping_sort">
205
                                        <input type="hidden" name="mapping_sort" value="[% mapping.sort %]" readonly />[% IF mapping.sort == 'undef' %]Undef[% ELSE %][% mapping.sort %][% END %]
196
                                [% IF mapping.sort == 'undef' %]
206
                                    </td>
197
                                  <option value="undef" selected="selected">Undef</option>
207
                                    <td>
198
                                [% ELSE %]
208
                                        <input type="hidden" name="mapping_facet" value="[% mapping.facet %]" readonly />[% IF mapping.facet == 1 %]Yes[% ELSE %]No[% END %]
199
                                  <option value="undef">Undef</option>
209
                                    </td>
200
                                [% END %]
210
                                    <td>
201
                                [% IF mapping.sort == 0 %]
211
                                        <input type="hidden" name="mapping_suggestible" value="[% mapping.suggestible %]" readonly />[% IF mapping.suggestible == 1 %]Yes[% ELSE %]No[% END %]
202
                                  <option value="0" selected="selected">0</option>
212
                                    </td>
203
                                [% ELSE %]
213
                                    <td>
204
                                  <option value="0">0</option>
214
                                        <input type="text" name="mapping_marc_field" value="[% mapping.marc_field %]" readonly />
205
                                [% END %]
215
                                    </td>
206
                                [% IF  mapping.sort == 1 %]
216
                                </tr>
207
                                  <option value="1" selected="selected">1</option>
217
                            [% ELSE %]
208
                                [% ELSE %]
218
                              <tr>
209
                                  <option value="1">1</option>
219
                                <td>
210
                                [% END %]
220
                                  <input type="hidden" name="mapping_index_name" value="[% index.index_name %]" />
211
                              </select>
221
                                  <input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name %]">
212
                            </td>
222
                              [% mapping.search_field_label %]
213
                            <td>
223
                                </td>
214
                              <select name="mapping_facet">
224
                                <td>
215
                                [% IF mapping.facet %]
225
                                  <select name="mapping_sort">
216
                                  <option value="0">No</option>
226
                                    [% IF mapping.sort == 'undef' %]
217
                                  <option value="1" selected="selected">Yes</option>
227
                                      <option value="undef" selected="selected">Undef</option>
218
                                [% ELSE %]
228
                                    [% ELSE %]
219
                                  <option value="0" selected="selected">No</option>
229
                                      <option value="undef">Undef</option>
220
                                  <option value="1">Yes</option>
230
                                    [% END %]
221
                                [% END %]
231
                                    [% IF mapping.sort == 0 %]
222
                              </select>
232
                                      <option value="0" selected="selected">0</option>
223
                            </td>
233
                                    [% ELSE %]
224
                            <td>
234
                                      <option value="0">0</option>
225
                              <select name="mapping_suggestible">
235
                                    [% END %]
226
                                [% IF mapping.suggestible %]
236
                                    [% IF  mapping.sort == 1 %]
227
                                  <option value="0">No</option>
237
                                      <option value="1" selected="selected">1</option>
228
                                  <option value="1" selected="selected">Yes</option>
238
                                    [% ELSE %]
229
                                [% ELSE %]
239
                                      <option value="1">1</option>
230
                                  <option value="0" selected="selected">No</option>
240
                                    [% END %]
231
                                  <option value="1">Yes</option>
241
                                  </select>
242
                                </td>
243
                                <td>
244
                                  <select name="mapping_facet">
245
                                    [% IF mapping.facet %]
246
                                      <option value="0">No</option>
247
                                      <option value="1" selected="selected">Yes</option>
248
                                    [% ELSE %]
249
                                      <option value="0" selected="selected">No</option>
250
                                      <option value="1">Yes</option>
251
                                    [% END %]
252
                                  </select>
253
                                </td>
254
                                <td>
255
                                  <select name="mapping_suggestible">
256
                                    [% IF mapping.suggestible %]
257
                                      <option value="0">No</option>
258
                                      <option value="1" selected="selected">Yes</option>
259
                                    [% ELSE %]
260
                                      <option value="0" selected="selected">No</option>
261
                                      <option value="1">Yes</option>
262
                                    [% END %]
263
                                  </select>
264
                                </td>
265
                                <td>
266
                                    <input name="mapping_marc_field" type="text" value="[% mapping.marc_field %]" />
267
                                </td>
268
                                <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td>
269
                              </tr>
232
                                [% END %]
270
                                [% END %]
233
                              </select>
271
                            [% END %]
234
                            </td>
235
                            <td>
236
                                <input name="mapping_marc_field" type="text" value="[% mapping.marc_field %]" />
237
                            </td>
238
                            <td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td>
239
                          </tr>
240
                        [% END %]
241
                      </tbody>
272
                      </tbody>
242
                      <tfoot>
273
                      <tfoot>
243
                        <tr class="nodrag nodrop">
274
                        <tr class="nodrag nodrop">
244
- 

Return to bug 19482