Bug 24559 - Elasticsearch - add support for 'year' fields
Summary: Elasticsearch - add support for 'year' fields
Status: RESOLVED DUPLICATE of bug 24807
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Elasticsearch (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Nick Clemens (kidclamp)
QA Contact:
URL:
Keywords:
: 25378 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-01-31 18:30 UTC by Nick Clemens (kidclamp)
Modified: 2020-05-06 13:16 UTC (History)
4 users (show)

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


Attachments
Bug 24559: Add 'year' type to Elasticsearch (7.98 KB, patch)
2020-02-26 02:31 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 24559: Database update (1.23 KB, patch)
2020-02-28 16:46 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 24559: Add 'year' type to Elasticsearch (8.03 KB, patch)
2020-02-28 19:39 UTC, Michal Denar
Details | Diff | Splinter Review
Bug 24559: Database update (1.28 KB, patch)
2020-02-28 19:39 UTC, Michal Denar
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens (kidclamp) 2020-01-31 18:30:01 UTC
There is a fixme in the code related to this. For dates like the 260c and 264c we need a way to parse p2014 into 2014 etc. This affects sorting on dates
Comment 1 AspenCat Team 2020-02-22 01:42:28 UTC
If sort by publication date is not working, it should probably not be an option. It is a nice option so it would be good to have fixed.  When results return more records than are easily reviewed it is nice to be able to sort either alphabetical by title (which is also not working) or publication date.
Comment 2 Nick Clemens (kidclamp) 2020-02-26 02:31:35 UTC
Created attachment 99626 [details] [review]
Bug 24559: Add 'year' type to Elasticsearch

When indexing fields like 260c or 008_/7-10 we need a way to format
these 'date' fields into years. Removing punctuation and coverting
unknown values to 0

To test:
 1 - Edit some records to have dates of publication in 008 like
    202u
    2021
    203u
    2039
 2 - Also add to title for all records a unique word like 'octoparrot'
 3 - Search for 'octoparrot'
 4 - Sort records by publication/copyrightdate
 5 - Confirm sorting is not as expected
 6 - Apply patch
 7 - Set copydate to 'year' type
 8 - Reindex
 9 - Repeat search
10 - Confirm sorting works as expected
Comment 3 Myka Kennedy Stephens 2020-02-28 01:02:02 UTC
Nick, I'm getting this error when I try to change copydate to Year:
An error occurred when updating mappings: DBIx::Class::Storage::DBI::_dbh_execute(): Data truncated for column 'type' at row 1 at /kohadevbox/koha/Koha/Object.pm line 156 . 

How do I fix that? (and how on earth did you come up with octoparrot??)
Comment 4 Nick Clemens (kidclamp) 2020-02-28 16:46:49 UTC
Created attachment 99785 [details] [review]
Bug 24559: Database update
Comment 5 Nick Clemens (kidclamp) 2020-02-28 16:48:33 UTC
(In reply to Myka Kennedy Stephens from comment #3)
> Nick, I'm getting this error when I try to change copydate to Year:
> An error occurred when updating mappings:
> DBIx::Class::Storage::DBI::_dbh_execute(): Data truncated for column 'type'
> at row 1 at /kohadevbox/koha/Koha/Object.pm line 156 . 
> 
> How do I fix that? (and how on earth did you come up with octoparrot??)

Hah, you need the update I didn't attach 

It's a Simpsons joke:
https://giphy.com/gifs/season-12-the-simpsons-12x9-3orifddyIN9i0I9tp6
"polly shouldn't be"
Comment 6 Michal Denar 2020-02-28 19:39:42 UTC
Created attachment 99791 [details] [review]
Bug 24559: Add 'year' type to Elasticsearch

When indexing fields like 260c or 008_/7-10 we need a way to format
these 'date' fields into years. Removing punctuation and coverting
unknown values to 0

To test:
 1 - Edit some records to have dates of publication in 008 like
    202u
    2021
    203u
    2039
 2 - Also add to title for all records a unique word like 'octoparrot'
 3 - Search for 'octoparrot'
 4 - Sort records by publication/copyrightdate
 5 - Confirm sorting is not as expected
 6 - Apply patch
 7 - Set copydate to 'year' type
 8 - Reindex
 9 - Repeat search
10 - Confirm sorting works as expected

Nice work, Nick.

Signed-off-by: Michal Denar <black23@gmail.com>
Comment 7 Michal Denar 2020-02-28 19:39:46 UTC
Created attachment 99792 [details] [review]
Bug 24559: Database update

Signed-off-by: Michal Denar <black23@gmail.com>
Comment 8 Julian Maurice 2020-05-06 06:35:58 UTC
*** Bug 25378 has been marked as a duplicate of this bug. ***
Comment 9 Nick Clemens (kidclamp) 2020-05-06 13:16:07 UTC
Resolving this in favor of 24807

*** This bug has been marked as a duplicate of bug 24807 ***