Bugzilla – Attachment 171988 Details for
Bug 24720
Remove special characters from beginning of sort fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24720: Strip special chars from sort fields
Bug-24720-Strip-special-chars-from-sort-fields.patch (text/plain), 1.73 KB, created by
Shi Yao Wang
on 2024-09-26 15:38:29 UTC
(
hide
)
Description:
Bug 24720: Strip special chars from sort fields
Filename:
MIME Type:
Creator:
Shi Yao Wang
Created:
2024-09-26 15:38:29 UTC
Size:
1.73 KB
patch
obsolete
>From 1d60b9a3ea1ccb1e154ace9b96b31d8549e9dd76 Mon Sep 17 00:00:00 2001 >From: David Gustafsson <david.gustafsson@ub.gu.se> >Date: Mon, 24 Feb 2020 15:47:31 +0100 >Subject: [PATCH] Bug 24720: Strip special chars from sort fields > >Strip all non alphanumerical characters from beginning >of sort field values so that sorting is performed on >the first alphanumeric character and not special characters >like "-" or "[". > >To test: > >1. Prepend "[" to the title of a biblio and save >2. Perform a search that matches this biblio and at least one > more biblio. >3. Sort alphabetically a-z. >4. The biblio with "[" should appear first >5. Apply the patch >6. Perform a full reindexing >7. Perform steps 2-3 again >8. The result should now be alphabetically sorted, > ignoring the initial bracket in the title. >9. Run tests in t/db_dependent/Koha/SearchEngine/Elasticsearch.t > >Signed-off-by: Shi Yao Wang <shi-yao.wang@inlibro.com> >--- > Koha/SearchEngine/Elasticsearch.pm | 2 ++ > 1 file changed, 2 insertions(+) > >diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm >index 5ef5235720..e724f06e5e 100644 >--- a/Koha/SearchEngine/Elasticsearch.pm >+++ b/Koha/SearchEngine/Elasticsearch.pm >@@ -799,6 +799,8 @@ sub marc_records_to_documents { > if ($field =~ /__sort$/) { > # Make sure to keep the sort field length sensible. 255 was chosen as a nice round value. > $record_document->{$field} = [substr(join(' ', @{$record_document->{$field}}), 0, 255)]; >+ # Strip any initial non-word characters which don't make much sense to sort on >+ $record_document->{$field} = [map { s/^\W+//u; $_ } @{$record_document->{$field}}]; > } > } > } >-- >2.34.1
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 24720
:
99556
|
111567
|
124759
|
124760
|
125209
|
125210
|
162674
| 171988 |
171989