Bug 38416 - Failover to MARCXML if cannot roundtrip USMARC when indexing
Summary: Failover to MARCXML if cannot roundtrip USMARC when indexing
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Elasticsearch (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: David Cook
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks: 27365
  Show dependency treegraph
 
Reported: 2024-11-11 03:55 UTC by David Cook
Modified: 2024-11-18 16:46 UTC (History)
5 users (show)

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


Attachments
Bug 38416: Failover to MARCXML if cannot roundtrip USMARC during indexing (2.44 KB, patch)
2024-11-11 04:41 UTC, David Cook
Details | Diff | Splinter Review
Bug 38416: Add unit tests (2.31 KB, patch)
2024-11-11 04:41 UTC, David Cook
Details | Diff | Splinter Review
Bug 38416: Tidy (3.57 KB, patch)
2024-11-11 22:19 UTC, David Cook
Details | Diff | Splinter Review
Bug 38416: Failover to MARCXML if cannot roundtrip USMARC during indexing (2.51 KB, patch)
2024-11-13 11:43 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38416: Add unit tests (2.37 KB, patch)
2024-11-13 11:43 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38416: Tidy (3.64 KB, patch)
2024-11-13 11:43 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38416: Failover to MARCXML if cannot roundtrip USMARC during indexing (2.60 KB, patch)
2024-11-15 07:59 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 38416: Add unit tests (2.47 KB, patch)
2024-11-15 07:59 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 38416: Tidy (3.73 KB, patch)
2024-11-15 07:59 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2024-11-11 03:55:42 UTC
In Koha/SearchEngine/Elasticsearch.pm, we already failover to MARCXML if the MARC record is over 99999 characters long.

There are other situations where USMARC cannot be generated correctly. For instance, when 1 field has over 9999 bytes. 

If we try roundtripping the USMARC and we get warnings, we should failover to MARCXML. We may get false positives, but it will prevent worse problems.
Comment 1 David Cook 2024-11-11 04:41:40 UTC
Created attachment 174318 [details] [review]
Bug 38416: Failover to MARCXML if cannot roundtrip USMARC during indexing

This change failsover to MARCXML from USMARC if there are any
warnings generated by MARC::File::USMARC::decode when trying to
roundtrip the record.

Test plan:
0. Apply the patch
1. Setup your koha-testing-docker to use Elasticsearch
2. Create a new record with 15,000 characters in the 500$a field
3. Index that record
(e.g. perl misc/search_tools/rebuild_elasticsearch.pl --biblios -v -v)
4. Note that a warning saying the following appears:
"Warnings encountered while roundtripping a MARC record to/from USMARC.
Failing over to MARCXML"
5. View the "Elasticsearch record" on the detail page and note that the
marc_format is MARCXML
6. Perform a search for the record (the keyword should be something that
brings up other results too)
7. Note that the record appears correctly in the search results
Comment 2 David Cook 2024-11-11 04:41:43 UTC
Created attachment 174319 [details] [review]
Bug 38416: Add unit tests
Comment 3 David Cook 2024-11-11 05:58:34 UTC
If we did push bug 38270, it would be tempting to failover to MARCXML_COMPRESSED actually...
Comment 4 David Cook 2024-11-11 06:01:28 UTC
Note: When rebuilding the koha-testing-docker Elasticsearch indexes, I noticed zero impact on indexing time by adding the roundtripping step.
Comment 5 David Cook 2024-11-11 22:19:24 UTC
Created attachment 174389 [details] [review]
Bug 38416: Tidy
Comment 6 Martin Renvoize (ashimema) 2024-11-13 11:43:54 UTC
Created attachment 174459 [details] [review]
Bug 38416: Failover to MARCXML if cannot roundtrip USMARC during indexing

This change failsover to MARCXML from USMARC if there are any
warnings generated by MARC::File::USMARC::decode when trying to
roundtrip the record.

Test plan:
0. Apply the patch
1. Setup your koha-testing-docker to use Elasticsearch
2. Create a new record with 15,000 characters in the 500$a field
3. Index that record
(e.g. perl misc/search_tools/rebuild_elasticsearch.pl --biblios -v -v)
4. Note that a warning saying the following appears:
"Warnings encountered while roundtripping a MARC record to/from USMARC.
Failing over to MARCXML"
5. View the "Elasticsearch record" on the detail page and note that the
marc_format is MARCXML
6. Perform a search for the record (the keyword should be something that
brings up other results too)
7. Note that the record appears correctly in the search results

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 7 Martin Renvoize (ashimema) 2024-11-13 11:43:56 UTC
Created attachment 174460 [details] [review]
Bug 38416: Add unit tests

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 8 Martin Renvoize (ashimema) 2024-11-13 11:43:58 UTC
Created attachment 174461 [details] [review]
Bug 38416: Tidy

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 9 Marcel de Rooy 2024-11-15 07:59:28 UTC
Created attachment 174542 [details] [review]
Bug 38416: Failover to MARCXML if cannot roundtrip USMARC during indexing

This change failsover to MARCXML from USMARC if there are any
warnings generated by MARC::File::USMARC::decode when trying to
roundtrip the record.

Test plan:
0. Apply the patch
1. Setup your koha-testing-docker to use Elasticsearch
2. Create a new record with 15,000 characters in the 500$a field
3. Index that record
(e.g. perl misc/search_tools/rebuild_elasticsearch.pl --biblios -v -v)
4. Note that a warning saying the following appears:
"Warnings encountered while roundtripping a MARC record to/from USMARC.
Failing over to MARCXML"
5. View the "Elasticsearch record" on the detail page and note that the
marc_format is MARCXML
6. Perform a search for the record (the keyword should be something that
brings up other results too)
7. Note that the record appears correctly in the search results

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 10 Marcel de Rooy 2024-11-15 07:59:30 UTC
Created attachment 174543 [details] [review]
Bug 38416: Add unit tests

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 11 Marcel de Rooy 2024-11-15 07:59:33 UTC
Created attachment 174544 [details] [review]
Bug 38416: Tidy

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 12 Katrin Fischer 2024-11-18 16:46:01 UTC
Pushed for 24.11!

Well done everyone, thank you!