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 1473-1479 CREATE TABLE `search_field` ( Link Here
1473
  `name` varchar(255) NOT NULL COMMENT 'the name of the field as it will be stored in the search engine',
1473
  `name` varchar(255) NOT NULL COMMENT 'the name of the field as it will be stored in the search engine',
1474
  `label` varchar(255) NOT NULL COMMENT 'the human readable name of the field, for display',
1474
  `label` varchar(255) NOT NULL COMMENT 'the human readable name of the field, for display',
1475
  `type` ENUM('', 'string', 'date', 'number', 'boolean', 'sum', 'isbn', 'stdno') NOT NULL COMMENT 'what type of data this holds, relevant when storing it in the search engine',
1475
  `type` ENUM('', 'string', 'date', 'number', 'boolean', 'sum', 'isbn', 'stdno') NOT NULL COMMENT 'what type of data this holds, relevant when storing it in the search engine',
1476
  `weight` int default NULL,
1476
  `weight` decimal(5,2) DEFAULT NULL,
1477
  PRIMARY KEY (`id`),
1477
  PRIMARY KEY (`id`),
1478
  UNIQUE KEY (`name` (191))
1478
  UNIQUE KEY (`name` (191))
1479
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1479
) 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 93-99 a.add, a.delete { Link Here
93
    <div class="warning">
93
    <div class="warning">
94
        Warning: Any changes to the configuration will only take effect after a full reindex. Until then searching may not work correctly.
94
        Warning: Any changes to the configuration will only take effect after a full reindex. Until then searching may not work correctly.
95
95
96
        <p>Weight: define weight between 1 and 99. Higher numbers indicate increased relevancy.
96
        <p>Weight: define weight as a positive number. Higher numbers indicate increased relevancy.
97
        <strong>Note that fields weighting works only for simple search.</strong></p>
97
        <strong>Note that fields weighting works only for simple search.</strong></p>
98
        <ol>
98
        <ol>
99
          <li>only search fields mapped with biblios can be weighted</li>
99
          <li>only search fields mapped with biblios can be weighted</li>
Lines 198-214 a.add, a.delete { Link Here
198
                          [% END %]
198
                          [% END %]
199
                        </select>
199
                        </select>
200
                      </td>
200
                      </td>
201
                      <td>
201
                      [% IF search_field.mapped_biblios %]
202
                      [% IF search_field.mapped_biblios %]
202
                        <td>
203
                        <input type="number" step="0.01" min="0" max="999" name="search_field_weight" value="[% search_field.weight %]" />
203
                          [% IF search_field.weight %]
204
                            <input type="number" name="search_field_weight" value="[% search_field.weight %]" min="1" max="99" />
205
                          [% ELSE %]
206
                            <input type="number" name="search_field_weight" min="1" max="99" />
207
                          [% END %]
208
                        </td>
209
                      [% ELSE %]
204
                      [% ELSE %]
210
                        <td><input type="hidden" name="search_field_weight" value=""></td>
205
                        <input type="hidden" name="search_field_weight" value="">
211
                      [% END %]
206
                      [% END %]
207
                      </td>
212
                    </tr>
208
                    </tr>
213
                  [% END %]
209
                  [% END %]
214
                </tbody>
210
                </tbody>
215
- 

Return to bug 18316