[Bug 44063] New: Component parts are not sorted by ComponentSortField and ComponentSortOrder
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44063 Bug ID: 44063 Summary: Component parts are not sorted by ComponentSortField and ComponentSortOrder Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Searching Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org Blocks: 34482 Target Milestone: --- Koha::Biblio->get_marc_components ignores the ComponentSortField and ComponentSortOrder preferences, so the component parts of a record (the Components tab, bugs 11175 and 30327) always come back in the search engine's default order. The cause is in Koha/Biblio.pm. get_components_query returns three values: return ( $query, $query_str, $sort ); but get_marc_components only unpacks two of them: my ( $searchstr, $sort ) = $self->get_components_query; so $sort holds the query string rather than the sort (for example title_za), and that is what is passed to search_compat. This came in with bug 30327. To test (found on a Zebra instance, not checked on Elasticsearch): 1. Set UseControlNumber to Use and ShowComponentRecords to both 2. Create a host record with a 001 and a 003, and three records linked to it: Leader position 7 'a' and a 773 $w with the host's control number, with titles that sort differently from the order they were created in 3. Set ComponentSortField to title and ComponentSortOrder to 'from Z to A' 4. Open the host record in the staff interface and look at the Components tab => The components are not sorted from Z to A. Changing ComponentSortOrder never changes the order. Calling search_compat directly with the sort 'title_za' does reverse it. The preference offers asc, dsc, az and za. Zebra understood title_az and title_za but not title_asc, so the values each search engine needs should be checked when fixing this, so that both get a sort they know. See also bug 29441 (make the returns of the Koha::Biblio get_marc_* methods consistent). Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34482 [Bug 34482] Improve MARC21 7xx linking fields in bibliographic records [Omnibus] -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44063 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=30327, | |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=29441, | |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=35117 -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44063 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 211465 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211465&action=edit Bug 44063: Apply ComponentSortField and ComponentSortOrder to the component parts search get_components_query returns ( $query, $query_str, $sort ), but get_marc_components only unpacked two of them: my ( $searchstr, $sort ) = $self->get_components_query; so $sort held the query string instead of the sort, and the component parts were never sorted by the preferences. Take the sort from the right place. To test: 1. Set UseControlNumber to Use and ShowComponentRecords to both 2. Create a host record with a 001 and a 003, and three records linked to it: Leader position 7 'a' and a 773 $w with the host's control number, with titles that sort differently from the order they were created in 3. Set ComponentSortField to title and ComponentSortOrder to 'from Z to A' 4. Open the host record in the staff interface and look at the Components tab => The components are not sorted from Z to A 5. Apply the patch and reload => The components are sorted from Z to A 6. Set ComponentSortOrder to 'from A to Z' => The components are sorted from A to Z 7. Run $ prove t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 8. Sign off -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44063 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff --- Comment #2 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- A correction to the description: the asc and dsc values work on Zebra too (title_asc and title_dsc are handled in C4/Search.pm). My first check made title_asc look ignored only because ascending was already the default order. The only cause is the unpacked return value. I have attached a patch with a test. I also checked it on a Zebra instance with ComponentSortOrder set to az, za, asc and dsc: without the patch the order never changes, and with it each value sorts as expected. Elasticsearch is only covered by the test, which checks the sort that is passed to the search, not by a real index. I am setting this to Needs Signoff. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44063 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44063 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44063 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211465|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44063 --- Comment #3 from David Nind <david@davidnind.com> --- Created attachment 211518 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211518&action=edit Bug 44063: Apply ComponentSortField and ComponentSortOrder to the component parts search get_components_query returns ( $query, $query_str, $sort ), but get_marc_components only unpacked two of them: my ( $searchstr, $sort ) = $self->get_components_query; so $sort held the query string instead of the sort, and the component parts were never sorted by the preferences. Take the sort from the right place. To test: 1. Set UseControlNumber to Use and ShowComponentRecords to both 2. Create a host record with a 001 and a 003, and three records linked to it: Leader position 7 'a' and a 773 $w with the host's control number, with titles that sort differently from the order they were created in 3. Set ComponentSortField to title and ComponentSortOrder to 'from Z to A' 4. Open the host record in the staff interface and look at the Components tab => The components are not sorted from Z to A 5. Apply the patch and reload => The components are sorted from Z to A 6. Set ComponentSortOrder to 'from A to Z' => The components are sorted from A to Z 7. Run $ prove t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 8. Sign off Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44063 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |david@davidnind.com --- Comment #4 from David Nind <david@davidnind.com> --- Testing notes (using KTD): 1. Tested on both Elasticsearch and Zebra: - Start up KTD with Elasticsearch: ktd --search-engine es9 up - Once finished testing with Elasticsearch change SearchEngine to Zebra (and reindex: koha-rebuild-zebra -d -f -v kohadev) 2. Can reproduce the issue using Zebra, but Elasticsearch seems to work as expected before the patch. 3. For the BKS framework make these tags and fields visible in the editor: - 003 - 773$w 4. Host record: - Programming Perl (262) - Edit record and add click 003 to add a value 5. Component records (change 000 position 7 to a, click in the 003 to add a value, add 17259930 to 773$w): - CGI programming with Perl (11) - Effective Perl programming (139) - Intermediate Perl (126) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44063 --- Comment #5 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- The "Easy piano pieces for children" record set from the original bug is very useful for testing this feature. Works nicely! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44063 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Small patch Status|Signed Off |Passed QA QA Contact|testopia@bugs.koha-communit |katrin.fischer@bsz-bw.de |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44063 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211518|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44063 --- Comment #6 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Created attachment 211559 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211559&action=edit Bug 44063: Apply ComponentSortField and ComponentSortOrder to the component parts search get_components_query returns ( $query, $query_str, $sort ), but get_marc_components only unpacked two of them: my ( $searchstr, $sort ) = $self->get_components_query; so $sort held the query string instead of the sort, and the component parts were never sorted by the preferences. Take the sort from the right place. To test: 1. Set UseControlNumber to Use and ShowComponentRecords to both 2. Create a host record with a 001 and a 003, and three records linked to it: Leader position 7 'a' and a 773 $w with the host's control number, with titles that sort differently from the order they were created in 3. Set ComponentSortField to title and ComponentSortOrder to 'from Z to A' 4. Open the host record in the staff interface and look at the Components tab => The components are not sorted from Z to A 5. Apply the patch and reload => The components are sorted from Z to A 6. Set ComponentSortOrder to 'from A to Z' => The components are sorted from A to Z 7. Run $ prove t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! 8. Sign off Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44063 --- Comment #7 from David Nind <david@davidnind.com> --- (In reply to Katrin Fischer from comment #5)
The "Easy piano pieces for children" record set from the original bug is very useful for testing this feature. Works nicely!
Thanks Katrin! That will indeed be useful. I've downloaded and added to my example records that I use for testing. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44063 --- Comment #8 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- (In reply to David Nind from comment #7)
(In reply to Katrin Fischer from comment #5)
The "Easy piano pieces for children" record set from the original bug is very useful for testing this feature. Works nicely!
Thanks Katrin! That will indeed be useful.
I've downloaded and added to my example records that I use for testing.
Glad you found it and sorry for not leaving the bug number, I also use a local copy I stored ages ago. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org