GenericSession doesn't currently handle sorting specified by the client. This needs to be added.
Created attachment 94655 [details] [review] Bug 23887: Add support for sorting in Z3950Responder. Also enables sorting by any field that supports sorting and no longer ignores invalid or unsupported sorts.
Is there some kind of test plan? I didn't quite understand where to put the sorting value by looking the code.
Sorry, got a mid-air collision when I was adding this: Test plan: Start responder: misc/z3950responder.pl Use browser to search: http://localhost:2100/biblios?version=1.2&operation=searchRetrieve&query=misth%20sortby%20title/ascending&maximumRecords=10&recordSchema=marcxml Compare with: http://localhost:2100/biblios?version=1.2&operation=searchRetrieve&query=misth%20sortby%20title/descending&maximumRecords=10&recordSchema=marcxml
Note that you could use any ES field as long as it's marked sortable in the search engine configuration. You can also specify multiple sort fields separated by a space: http://localhost:2100/biblios?version=1.2&operation=searchRetrieve&query=misth%20sortby%20title/ascending%20author&maximumRecords=10&recordSchema=marcxml
I added the url to SRU docs about sorting. Note that we currently only support specifying sort fields and direction.
Hi Ere. Could you provide some more information on how to get the z3950responder.pl working and I'd be happy to test? I've looked at https://wiki.koha-community.org/wiki/Setting_up_the_Z39.50_and_SRU_Server but I get an error when going koha-z3950-responder --enable kohadev (using koha-testing-docker): cp: cannot stat '/etc/koha/z3950/*': No such file or directory David Nind
David, Sorry for the slow response, I was away. I think the enabling script should take care of that, but apparently it doesn't, so could you try creating the directory manually e.g. by running `mkdir -p /etc/koha/z3950` ?
Thanks Ere! No problem, will have a look at testing this as soon as I can.
Created attachment 117290 [details] [review] Bug 23887: Add support for sorting in Z3950Responder. Also enables sorting by any field that supports sorting and no longer ignores invalid or unsupported sorts.
(In reply to Ere Maijala from comment #3) > Test plan: > > Start responder: misc/z3950responder.pl At this stage I get an error: syntax error at /kohadevbox/koha/Koha/Z3950Responder/GenericSession.pm line 135, near "}" Compilation failed in require at /kohadevbox/koha/Koha/Z3950Responder.pm line 161. BEGIN failed--compilation aborted at /kohadevbox/koha/Koha/Z3950Responder.pm line 161. Compilation failed in require at misc/z3950_responder.pl line 28. BEGIN failed--compilation aborted at misc/z3950_responder.pl line 28. Could you add the test plan to the commit message when you revise it?
Created attachment 117967 [details] [review] Bug 23887: Add support for sorting in Z3950Responder. Also enables sorting by any field that supports sorting and no longer ignores invalid or unsupported sorts. Test plan: 1. Run tests: prove -v t/db_dependent/Koha/Z3950Responder/ 2. Start responder: misc/z3950responder.pl 3. Use browser to search: http://localhost:2100/biblios?version=1.2&operation=searchRetrieve&query=misth%20sortby%20title/ascending&maximumRecords=10&recordSchema=marcxml 4. Compare with: http://localhost:2100/biblios?version=1.2&operation=searchRetrieve&query=misth%20sortby%20title/descending&maximumRecords=10&recordSchema=marcxml
Sorry, the patch was somehow completely broken. Now fixed, and I added a test while at it.
The patch still applies, however the sorting doesn't work for me. Testing notes using koha-testing-docker: - Getting the Z3950Responder to work in koha-testing-docker: . the Z3950Responder is setup and running by default (but you can't accessing using your browser) . commands: ~ koha-z3950-responder --stop kohadev ~ koha-z3950-responder --start kohadev ~ a restart_all will also reload it . it is running on port 2100, however this is not accessible using the browser . to enable access using the browser: ~ edit your docker-compose.yml file in koha-testing-docker ~ add port 2100 in the koha services section, for example: ports: - "8080:8080" - "8081:8081" - "2100:2100" <== this was added ~ close koha-testing-docker down and restart (Ctrl-C and kd, then ku) - Alternative: use the queries with curl from kshell and output to a file to make it easier to review the results: curl "queries from the next step" > filename - I changed the query to search for perl, as "misth" is not in the sample data: . http://localhost:2100/biblios?version=1.2&operation=searchRetrieve&query=perl sortby title/ascending&maximumRecords=10&recordSchema=marcxml" . http://localhost:2100/biblios?version=1.2&operation=searchRetrieve&query=perl sortby title/descending&maximumRecords=10&recordSchema=marcxml" - For me, the order of the results didn't change, and they appeared in this order before and after the patch was applied, and when using ascending and descending: Perl best practices CGI programming with Perl Programming the Perl DBI Perl Hacks Intermediate Perl Effective Perl programming The definitive guide to Catalyst Higher-order Perl Perl Better Practices Perl template toolkit - The tests passed before and after the patch was applied - Tip: Firefox returns raw XML, I used Google Chrome so that the page was more readable