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

(-)a/admin/searchengine/elasticsearch/mappings.pl (-1 / +2 lines)
Lines 17-22 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
use CGI;
19
use CGI;
20
use Scalar::Util qw(looks_like_number);
20
use C4::Koha;
21
use C4::Koha;
21
use C4::Output;
22
use C4::Output;
22
use C4::Auth;
23
use C4::Auth;
Lines 71-77 if ( $op eq 'edit' ) { Link Here
71
            my $search_field = Koha::SearchFields->find( { name => $field_name }, { key => 'name' } );
72
            my $search_field = Koha::SearchFields->find( { name => $field_name }, { key => 'name' } );
72
            $search_field->label($field_label);
73
            $search_field->label($field_label);
73
            $search_field->type($field_type);
74
            $search_field->type($field_type);
74
            $search_field->weight($field_weight || '');
75
            $search_field->weight($field_weight) if looks_like_number($field_weight) && $field_weight > 0;
75
            $search_field->store;
76
            $search_field->store;
76
        }
77
        }
77
78
(-)a/installer/data/mysql/atomicupdate/bug_18316_add-weight-column.perl (-2 / +2 lines)
Lines 1-9 Link Here
1
$DBversion = 'XXX';
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
2
if( CheckVersion( $DBversion ) ) {
3
    if( !column_exists( 'search_field', 'weight' ) ) {
3
    if( !column_exists( 'search_field', 'weight' ) ) {
4
        $dbh->do( "ALTER TABLE search_field ADD COLUMN weight int" );
4
        $dbh->do( "ALTER TABLE `search_field` ADD COLUMN `weight` decimal(5,2) DEFAULT NULL" );
5
    }
5
    }
6
6
7
    SetVersion( $DBversion );
7
    SetVersion( $DBversion );
8
    print "Upgrade to $DBversion done (Bug 18316 - Add column search_field.weight)\n";
8
    print "Upgrade to $DBversion done (Bug 18316 - Add column search_field.weight)\n";
9
}
9
}
(-)a/installer/data/mysql/kohastructure.sql (-1 / +1 lines)
Lines 1460-1466 CREATE TABLE `search_field` ( Link Here
1460
  `name` varchar(255) NOT NULL COMMENT 'the name of the field as it will be stored in the search engine',
1460
  `name` varchar(255) NOT NULL COMMENT 'the name of the field as it will be stored in the search engine',
1461
  `label` varchar(255) NOT NULL COMMENT 'the human readable name of the field, for display',
1461
  `label` varchar(255) NOT NULL COMMENT 'the human readable name of the field, for display',
1462
  `type` ENUM('', 'string', 'date', 'number', 'boolean', 'sum') NOT NULL COMMENT 'what type of data this holds, relevant when storing it in the search engine',
1462
  `type` ENUM('', 'string', 'date', 'number', 'boolean', 'sum') NOT NULL COMMENT 'what type of data this holds, relevant when storing it in the search engine',
1463
  `weight` int default NULL,
1463
  `weight` decimal(5,2) DEFAULT NULL,
1464
  PRIMARY KEY (`id`),
1464
  PRIMARY KEY (`id`),
1465
  UNIQUE KEY (`name` (191))
1465
  UNIQUE KEY (`name` (191))
1466
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1466
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt (-10 / +5 lines)
Lines 91-97 a.add, a.delete { Link Here
91
    <div class="warning">
91
    <div class="warning">
92
        Warning: Any changes to the configuration will only take effect after a full reindex. Until then searching may not work correctly.
92
        Warning: Any changes to the configuration will only take effect after a full reindex. Until then searching may not work correctly.
93
93
94
        <p>Weight: define weight between 1 and 99. Higher numbers indicate increased relevancy.
94
        <p>Weight: define weight as a positive number. Higher numbers indicate increased relevancy.
95
        <strong>Note that fields weighting works only for simple search.</strong></p>
95
        <strong>Note that fields weighting works only for simple search.</strong></p>
96
        <ol>
96
        <ol>
97
          <li>only search fields mapped with biblios can be weighted</li>
97
          <li>only search fields mapped with biblios can be weighted</li>
Lines 174-190 a.add, a.delete { Link Here
174
                          [% END %]
174
                          [% END %]
175
                        </select>
175
                        </select>
176
                      </td>
176
                      </td>
177
                      <td>
177
                      [% IF search_field.mapped_biblios %]
178
                      [% IF search_field.mapped_biblios %]
178
                        <td>
179
                        <input type="number" step="0.01" min="0" max="999" name="search_field_weight" value="[% search_field.weight %]" />
179
                          [% IF search_field.weight %]
180
                            <input type="number" name="search_field_weight" value="[% search_field.weight %]" min="1" max="99" />
181
                          [% ELSE %]
182
                            <input type="number" name="search_field_weight" min="1" max="99" />
183
                          [% END %]
184
                        </td>
185
                      [% ELSE %]
180
                      [% ELSE %]
186
                        <td><input type="hidden" name="search_field_weight" value=""></td>
181
                        <input type="hidden" name="search_field_weight" value="">
187
                      [% END %]
182
                      [% END %]
183
                      </td>
188
                    </tr>
184
                    </tr>
189
                  [% END %]
185
                  [% END %]
190
                </tbody>
186
                </tbody>
191
- 

Return to bug 18316