Bugzilla – Attachment 75458 Details for
Bug 18316
Add weighting/relevancy options to ElasticSearch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Change search field weight field to decimal and add column declaration to DBIx results source
Change-search-field-weight-field-to-decimal-and-ad.patch (text/plain), 5.63 KB, created by
David Gustafsson
on 2018-05-21 12:26:29 UTC
(
hide
)
Description:
Change search field weight field to decimal and add column declaration to DBIx results source
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2018-05-21 12:26:29 UTC
Size:
5.63 KB
patch
obsolete
>From d61ca54db48eb305d34af8a9d6a25dbee3272517 Mon Sep 17 00:00:00 2001 >From: David Gustafsson <david.gustafsson@ub.gu.se> >Date: Mon, 21 May 2018 14:24:36 +0200 >Subject: [PATCH] Change search field weight field to decimal and add column > declaration to DBIx results source > >https://bugs.koha-community.org/show_bug.cgi?id=18316 >--- > Koha/Schema/Result/SearchField.pm | 2 ++ > admin/searchengine/elasticsearch/mappings.pl | 3 ++- > .../mysql/atomicupdate/bug_18316_add-weight-column.perl | 4 ++-- > installer/data/mysql/kohastructure.sql | 2 +- > .../modules/admin/searchengine/elasticsearch/mappings.tt | 14 +++++--------- > 5 files changed, 12 insertions(+), 13 deletions(-) > >diff --git a/Koha/Schema/Result/SearchField.pm b/Koha/Schema/Result/SearchField.pm >index ee32f42cf2..9ae287a829 100644 >--- a/Koha/Schema/Result/SearchField.pm >+++ b/Koha/Schema/Result/SearchField.pm >@@ -68,6 +68,8 @@ __PACKAGE__->add_columns( > extra => { list => ["", "string", "date", "number", "boolean", "sum"] }, > is_nullable => 0, > }, >+ "weight", >+ { data_type => "decimal", size => [ 5, 2 ], is_nullable => 1 }, > ); > > =head1 PRIMARY KEY >diff --git a/admin/searchengine/elasticsearch/mappings.pl b/admin/searchengine/elasticsearch/mappings.pl >index 0c5def7680..6a167497c6 100755 >--- a/admin/searchengine/elasticsearch/mappings.pl >+++ b/admin/searchengine/elasticsearch/mappings.pl >@@ -17,6 +17,7 @@ > > use Modern::Perl; > use CGI; >+use Scalar::Util qw(looks_like_number); > use C4::Koha; > use C4::Output; > use C4::Auth; >@@ -71,7 +72,7 @@ if ( $op eq 'edit' ) { > my $search_field = Koha::SearchFields->find( { name => $field_name }, { key => 'name' } ); > $search_field->label($field_label); > $search_field->type($field_type); >- $search_field->weight($field_weight || ''); >+ $search_field->weight($field_weight) if looks_like_number($field_weight) && $field_weight > 0; > $search_field->store; > } > >diff --git a/installer/data/mysql/atomicupdate/bug_18316_add-weight-column.perl b/installer/data/mysql/atomicupdate/bug_18316_add-weight-column.perl >index 185a2b5565..a076d8b402 100644 >--- a/installer/data/mysql/atomicupdate/bug_18316_add-weight-column.perl >+++ b/installer/data/mysql/atomicupdate/bug_18316_add-weight-column.perl >@@ -1,9 +1,9 @@ > $DBversion = 'XXX'; > if( CheckVersion( $DBversion ) ) { > if( !column_exists( 'search_field', 'weight' ) ) { >- $dbh->do( "ALTER TABLE search_field ADD COLUMN weight int" ); >+ $dbh->do( "ALTER TABLE `search_field` ADD COLUMN `weight` decimal(5,2) DEFAULT NULL" ); > } > > SetVersion( $DBversion ); > print "Upgrade to $DBversion done (Bug 18316 - Add column search_field.weight)\n"; >-} >\ No newline at end of file >+} >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index d604e63345..5ad168e89c 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -1460,7 +1460,7 @@ CREATE TABLE `search_field` ( > `name` varchar(255) NOT NULL COMMENT 'the name of the field as it will be stored in the search engine', > `label` varchar(255) NOT NULL COMMENT 'the human readable name of the field, for display', > `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', >- `weight` int default NULL, >+ `weight` decimal(5,2) DEFAULT NULL, > PRIMARY KEY (`id`), > UNIQUE KEY (`name` (191)) > ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt >index 728fd2b820..dd9522e2b0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt >@@ -91,7 +91,7 @@ a.add, a.delete { > <div class="warning"> > Warning: Any changes to the configuration will only take effect after a full reindex. Until then searching may not work correctly. > >- <p>Weight: define weight between 1 and 99. Higher numbers indicate increased relevancy. >+ <p>Weight: define weight as a positive number. Higher numbers indicate increased relevancy. > <strong>Note that fields weighting works only for simple search.</strong></p> > <ol> > <li>only search fields mapped with biblios can be weighted</li> >@@ -184,17 +184,13 @@ a.add, a.delete { > [% END %] > </select> > </td> >+ <td> > [% IF search_field.mapped_biblios %] >- <td> >- [% IF search_field.weight %] >- <input type="number" name="search_field_weight" value="[% search_field.weight %]" min="1" max="99" /> >- [% ELSE %] >- <input type="number" name="search_field_weight" min="1" max="99" /> >- [% END %] >- </td> >+ <input type="text" size="4" name="search_field_weight" value="[% search_field.weight %]" /> > [% ELSE %] >- <td><input type="hidden" name="search_field_weight" value=""></td> >+ <input type="hidden" name="search_field_weight" value=""> > [% END %] >+ </td> > </tr> > [% END %] > </tbody> >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18316
:
61472
|
73139
|
73140
|
73492
|
73493
|
73600
|
73601
|
74112
|
74115
|
74116
|
74117
|
74714
|
74720
|
74751
|
74752
|
74753
|
74754
|
75073
|
75074
|
75075
|
75076
|
75458
|
75490
|
75519
|
75520
|
75521
|
75522
|
75523
|
75524
|
75525
|
75526
|
75527
|
75528
|
75529
|
75530
|
75531
|
75536
|
75537
|
75538
|
75539
|
75540
|
75541
|
75699
|
75730
|
77661
|
77662
|
77663
|
77664
|
77665
|
77666
|
77667
|
78396
|
78397
|
78398
|
78399
|
78400
|
78401
|
78402
|
78403
|
80278
|
80335
|
81004
|
81005
|
81006
|
81007
|
81008
|
81009
|
81010
|
81011
|
81012
|
81507
|
81508
|
81509
|
81510
|
81511
|
81512
|
81513
|
81514
|
81515
|
81516
|
82050