Bug 31076 - Bug 22605 breaks date of publication range search
Summary: Bug 22605 breaks date of publication range search
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Elasticsearch (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Nick Clemens
QA Contact:
URL:
Keywords: regression
Depends on: 22605
Blocks:
  Show dependency treegraph
 
Reported: 2022-07-01 08:50 UTC by Fridolin Somers
Modified: 2022-10-23 09:49 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes the date of publication range searching in the staff interface when using Elasticsearch. It was working in the OPAC, but not the staff interface - caused by a regression from Bug 22605 introduced in Koha 22.05. For example: a search for 2005-2010 in the staff interface advanced search will now display the same results as the OPAC.
Version(s) released in:
22.11.00,21.11.12


Attachments
Bug 31076: Handle year limits with equal sign or colon (2.85 KB, patch)
2022-07-01 11:14 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 31076: Handle year limits with equal sign or colon (3.22 KB, patch)
2022-08-18 16:18 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 31076: Handle year limits with equal sign or colon (3.27 KB, patch)
2022-08-18 21:42 UTC, David Nind
Details | Diff | Splinter Review
Bug 31076: Handle year limits with equal sign or colon (3.33 KB, patch)
2022-08-19 19:28 UTC, Fridolin Somers
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Fridolin Somers 2022-07-01 08:50:33 UTC
Bug 22605 changed in staff interface the date of publication limit :
       - $limit_yr = "yr,st-numeric=$params->{'limit-yr'}";
       + $limit_yr = "yr,st-numeric:$params->{'limit-yr'}";

This breaks the range search on date of publication which is a special case in QueryBuilder :
https://git.koha-community.org/Koha-community/Koha/src/commit/6c315c164dbcf3e05fcfe4a3110b824ab3ac162c/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm#L1058

Maybe juste allow ":" or "=" :
  my ($date) = ( $l =~ /^yr,st-numeric[=:](.*)$/ );
Comment 1 Nick Clemens 2022-07-01 11:14:38 UTC
Created attachment 136805 [details] [review]
Bug 31076: Handle year limits with equal sign or colon

To test:
1 - Enable ES and index
2 - Set expandedSearchOption to 'show'
3 - Advanced search on staff and opac using Year field on staff and Publication date range on OPAC for:
    2005
    2005-
    -2005
    <2005
    >2005
    2005-2010
4 - Confirm ranges don't work on staff side, but do on opac
5 - Apply patch
6 - Repeat searches - they work on both staff and opac
7 - prove t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t
Comment 2 Fridolin Somers 2022-07-02 01:22:38 UTC
Great.

We should do the same with above lines :

        if ( $l =~ /^yr,st-numeric,ge=/ ) {
            my ( $start, $end ) =
              ( $l =~ /^yr,st-numeric,ge=(.*) and yr,st-numeric,le=(.*)$/ );
Comment 3 David Nind 2022-07-03 10:58:32 UTC
Patch no longer applies 8-(..

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 31076: Handle year limits with equal sign or colon
Using index info to reconstruct a base tree...
M	Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
M	t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t
Falling back to patching base and 3-way merge...
Auto-merging t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t
CONFLICT (content): Merge conflict in t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t
Auto-merging Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
error: Failed to merge in the changes.
Patch failed at 0001 Bug 31076: Handle year limits with equal sign or colon
Comment 4 Nick Clemens 2022-08-18 16:18:08 UTC
Created attachment 139405 [details] [review]
Bug 31076: Handle year limits with equal sign or colon

To test:
1 - Enable ES and index
2 - Set expandedSearchOption to 'show'
3 - Advanced search on staff and opac using Year field on staff and Publication date range on OPAC for:
    2005
    2005-
    -2005
    <2005
    >2005
    2005-2010
4 - Confirm ranges don't work on staff side, but do on opac
5 - Apply patch
6 - Repeat searches - they work on both staff and opac
7 - prove t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t
Comment 5 David Nind 2022-08-18 21:42:19 UTC
Created attachment 139437 [details] [review]
Bug 31076: Handle year limits with equal sign or colon

To test:
1 - Enable ES and index
2 - Set expandedSearchOption to 'show'
3 - Advanced search on staff and opac using Year field on staff and Publication date range on OPAC for:
    2005
    2005-
    -2005
    <2005
    >2005
    2005-2010
4 - Confirm ranges don't work on staff side, but do on opac
5 - Apply patch
6 - Repeat searches - they work on both staff and opac
7 - prove t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t

Signed-off-by: David Nind <david@davidnind.com>
Comment 6 Fridolin Somers 2022-08-19 19:28:03 UTC
Created attachment 139520 [details] [review]
Bug 31076: Handle year limits with equal sign or colon

To test:
1 - Enable ES and index
2 - Set expandedSearchOption to 'show'
3 - Advanced search on staff and opac using Year field on staff and Publication date range on OPAC for:
    2005
    2005-
    -2005
    <2005
    >2005
    2005-2010
4 - Confirm ranges don't work on staff side, but do on opac
5 - Apply patch
6 - Repeat searches - they work on both staff and opac
7 - prove t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Comment 7 Fridolin Somers 2022-08-19 19:29:15 UTC
Go Elastic-team go :D
Comment 8 Tomás Cohen Arazi 2022-08-19 19:31:46 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 9 Lucas Gass 2022-10-14 19:37:58 UTC
Backported to 22.05.x for upcoming 22.05.06 release
Comment 10 Victor Grousset/tuxayo 2022-10-21 22:23:36 UTC
Missing dependencies for 21.05.x, it shouldn't be affected, no backport.
Nothing to document it seems, marking resolved.
Comment 11 Arthur Suzuki 2022-10-22 22:08:39 UTC
Thanks!

Pushed to 21.11 for 21.11.12