Bug 23887 - Add support for client-specified sort order in Z3950Responder
Summary: Add support for client-specified sort order in Z3950Responder
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Z39.50 / SRU / OpenSearch Servers (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Ere Maijala
QA Contact: Testopia
URL: http://www.loc.gov/standards/sru/cql/...
Keywords:
Depends on: 23089
Blocks:
  Show dependency treegraph
 
Reported: 2019-10-24 07:57 UTC by Ere Maijala
Modified: 2022-06-01 19:25 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 23887: Add support for sorting in Z3950Responder. (3.12 KB, patch)
2019-10-24 11:10 UTC, Ere Maijala
Details | Diff | Splinter Review
Bug 23887: Add support for sorting in Z3950Responder. (3.12 KB, patch)
2021-02-25 07:49 UTC, Ere Maijala
Details | Diff | Splinter Review
Bug 23887: Add support for sorting in Z3950Responder. (6.74 KB, patch)
2021-03-09 12:47 UTC, Ere Maijala
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Ere Maijala 2019-10-24 07:57:54 UTC
GenericSession doesn't currently handle sorting specified by the client. This needs to be added.
Comment 1 Ere Maijala 2019-10-24 11:10:23 UTC
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.
Comment 2 Johanna Räisä 2019-10-24 11:32:24 UTC
Is there some kind of test plan? I didn't quite understand where to put the sorting value by looking the code.
Comment 4 Ere Maijala 2019-10-24 12:08:18 UTC
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
Comment 5 Ere Maijala 2019-10-25 07:41:16 UTC
I added the url to SRU docs about sorting. Note that we currently only support specifying sort fields and direction.
Comment 6 David Nind 2020-03-15 18:59:38 UTC
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
Comment 7 Ere Maijala 2020-05-11 10:06:08 UTC
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` ?
Comment 8 David Nind 2020-05-12 10:55:46 UTC
Thanks Ere! No problem, will have a look at testing this as soon as I can.
Comment 9 Ere Maijala 2021-02-25 07:49:53 UTC
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.
Comment 10 Owen Leonard 2021-02-25 16:12:46 UTC
(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?
Comment 11 Ere Maijala 2021-03-09 12:47:59 UTC
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
Comment 12 Ere Maijala 2021-03-09 12:48:48 UTC
Sorry, the patch was somehow completely broken. Now fixed, and I added a test while at it.
Comment 13 David Nind 2022-06-01 19:25:12 UTC
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