10 commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
Frank Hansen
|
8c7230b802
|
Bug 30280: Add support for subject headings from different thesaurus when using Elasticsearch
This patch allows subject headings from different thesaurus to co-exist in Koha. Test plan: 1. Enable Elasticsearch as the search engine (SearchEngine system preference = Elasticsearch) and reindex (koha-elasticsearch --rebuild -d -b -a kohadev). 2. Load sample authority records attached to the bug (in this case the authorities.mrc file was saved in the koha directory - adjust file location as appropriate): misc/migration_tools/bulkmarcimport.pl -v -a -file authorities.mrc -insert -c=MARC21 3. Load the sample bibliographic record attached to the bug: misc/migration_tools/bulkmarcimport.pl -v -b -file biblios.mrc -insert -c=MARC21 4. Search for ISBN 0704328623 and verify that the subject terms are not linked to any authority records (if you hover over the link terms, all links should look like ../cgi-bin/koha/catalogue/search.pl?q=su:"subjectterm" - none should have any ?q=an:XXX (where XXX = authority record ids) in the link). 5. Apply the patches. 6. Reset the Elasticsearch mappings (Administration > Catalog > Search engine configuration (Elasticsearch)). 7. Reindex: koha-elasticsearch --rebuild -d -b -a kohadev 8. Link bibliographic records to authority records: misc/link_bibs_to_authorities.pl -v -l 9. Repeat the search in step 4 (or refresh the record details page) and verify that the first three Feminism headings[1] are linked to an authority record (should have ?q=an:XXX (where XXX = different authority record IDs for the various feminism authority records linked to a specific thesaurus)). 10. Reindex: koha-elasticsearch --rebuild -d -b -a kohadev [1] Links for subject terms for step 9 in order are (the authority ids may be different depending on how ou are testing): Subject(s:) Feminism | feminism | Feminism | Feminism | Idéhistoria | Litteratur http://127.0.0.1:8081/cgi-bin/koha/catalogue/search.pl?q=an:1709 http://127.0.0.1:8081/cgi-bin/koha/catalogue/search.pl?q=an:1710 http://127.0.0.1:8081/cgi-bin/koha/catalogue/search.pl?q=an:1708 http://127.0.0.1:8081/cgi-bin/koha/catalogue/search.pl?q=su:"Feminism" http://127.0.0.1:8081/cgi-bin/koha/catalogue/search.pl?q=su:"Idéhistoria" http://127.0.0.1:8081/cgi-bin/koha/catalogue/search.pl?q=su:"Litteratur" MARC info: 650 #7 - SUBJECT ADDED ENTRY--TOPICAL TERM a Topical term or geographic name entry element Feminism 0 Authority record control number or standard number https://id.kb.se/term/sao/Feminism 2 Source of heading or term sao 650 #7 - SUBJECT ADDED ENTRY--TOPICAL TERM a Topical term or geographic name entry element feminism 2 Source of heading or term bnb 650 #0 - SUBJECT ADDED ENTRY--TOPICAL TERM a Topical term or geographic name entry element Feminism 650 #4 - SUBJECT ADDED ENTRY--TOPICAL TERM a Topical term or geographic name entry element Feminism 650 #4 - SUBJECT ADDED ENTRY--TOPICAL TERM a Topical term or geographic name entry element Idéhistoria 650 #4 - SUBJECT ADDED ENTRY--TOPICAL TERM a Topical term or geographic name entry element Litteratur Note: The fourth Feminism term has second indicator 4 which means "Source not specified". So this term is only a local term and does not belong to any specific thesaurus and thus not linked. To specify a source of a term, the second indicator must be set as 7. The source of heading is then specified in subfield 2. Sponsored-by: Lund University Library, Sweden Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> |
||
ea88cfb3ab |
Bug 28676: Cache and retrieve match_count when searching a cached heading
We use match_count to determine if a new authority record should be created, however, we were not adding this count to the cache, so if a record returned too many matches on first lookup, we would create a new record on the second lookup To test: 1 - Set Linker Module to 'Default' 2 - Enable AutoCreateAuthorities and BiblioAddsAuthorities and CatalogModuleRelink and LinkerRelink 3 - Add two copies of a single authority via Z39 4 - Add two headings for that authority to a bib record (e.g. a 610 and 710) 5 - Save the record and note a new authority is generated 6 - Repeat and see another is generated 7 - Apply patch 8 - Restart all the things 9 - Save the record again, no new authority created Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org> Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> |
|||
9d6d641d1f |
Bug 17600: Standardize our EXPORT_OK
On bug 17591 we discovered that there was something weird going on with the way we export and use subroutines/modules. This patch tries to standardize our EXPORT to use EXPORT_OK only. That way we will need to explicitely define the subroutine we want to use from a module. This patch is a squashed version of: Bug 17600: After export.pl Bug 17600: After perlimport Bug 17600: Manual changes Bug 17600: Other manual changes after second perlimports run Bug 17600: Fix tests And a lot of other manual changes. export.pl is a dirty script that can be found on bug 17600. "perlimport" is: git clone https://github.com/oalders/App-perlimports.git cd App-perlimports/ cpanm --installdeps . export PERL5LIB="$PERL5LIB:/kohadevbox/koha/App-perlimports/lib" find . \( -name "*.pl" -o -name "*.pm" \) -exec perl App-perlimports/script/perlimports --inplace-edit --no-preserve-unused --filename {} \; The ideas of this patch are to: * use EXPORT_OK instead of EXPORT * perltidy the EXPORT_OK list * remove '&' before the subroutine names * remove some uneeded use statements * explicitely import the subroutines we need within the controllers or modules Note that the private subroutines (starting with _) should not be exported (and not used from outside of the module except from tests). EXPORT vs EXPORT_OK (from https://www.thegeekstuff.com/2010/06/perl-exporter-examples/) """ Export allows to export the functions and variables of modules to user’s namespace using the standard import method. This way, we don’t need to create the objects for the modules to access it’s members. @EXPORT and @EXPORT_OK are the two main variables used during export operation. @EXPORT contains list of symbols (subroutines and variables) of the module to be exported into the caller namespace. @EXPORT_OK does export of symbols on demand basis. """ If this patch caused a conflict with a patch you wrote prior to its push: * Make sure you are not reintroducing a "use" statement that has been removed * "$subroutine" is not exported by the C4::$MODULE module means that you need to add the subroutine to the @EXPORT_OK list * Bareword "$subroutine" not allowed while "strict subs" means that you didn't imported the subroutine from the module: - use $MODULE qw( $subroutine list ); You can also use the fully qualified namespace: C4::$MODULE::$subroutine Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> |
|||
980419ed15 |
Bug 25189: Don't create authority if results found
Automatic authority creation assumes that if we don't match we need a new authority. Using the Default linker, however, we don't match if there exists more than one match. This leads to repeatedly generating authorities once there is a duplicate in the system We shoudl instead only create a new authority if there are no results To test: 1 - Set Linker Module to 'Default' 2 - Enable AutoCreateAuthorities and BiblioAddsAuthorities and CatalogModuleRelink and LinkerRelink 3 - Add two copies of a single authority via Z39 4 - Add a heading for that authority to a bib record 5 - Save the record and note a new authority is generated 6 - Repeat and see another is generated 7 - Apply patch 8 - Restart all the things 9 - Save the record again, no new authority created Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> |
|||
d4783f244b
|
Bug 24269: Adjust C4::Heading to generate headings from auth tags
To test: 1 - Be using Elasticsearch 2 - Check that field 150 is mapped to 'Match-heading' or add it (the subfields don't matter) 3 - Add a topic term authority record like "150 $aCats$vFiction" 4 - Add a 650 with $aCats and $vFiction and $e depicted to a bibliographic record 5 - Run the linker for the bib perl misc/link_bibs_to_authorities.pl --bib-limit "biblionumber=89" -v 6 - Confirm the record is not correctly linked to the record 7 - Apply patch 8 - Reindex authorities for ES perl misc/search_tools/rebuild_elasticsearch.pl -v -d -a 9 - Run the linker and confirm record is correctly linked perl misc/link_bibs_to_authorities.pl --bib-limit "biblionumber=89" -v Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Bouzid Fergani <bouzid.fergani@inlibro.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> |
|||
848a0d41ff |
Bug 21450: Cache authorities search using term and auth_type
This is a simple fix to prevent incorrect caching of results when using link_bibs_to_authorities To test: 1 - Find or create a record with the same term in a subject and genre heading 2 - Find or create authority records for the term as a subject and genre type 3 - Run link bibs to authorities 4 - Verify both tags in the record are linked to the subject heading 5 - Aply patch 6 - Unlink the record and re-run the script (or just re-run) 7 - Each tag should be linked to correct authority Signed-off-by: Frank Hansen <frank.hansen@ub.lu.se> Signed-off-by: Liz Rea <wizzyrea@gmail.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> |
|||
Jonathan Druart
|
a6c9bd0eb5 |
Bug 9978: Replace license header with the correct license (GPLv3+)
Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> http://bugs.koha-community.org/show_bug.cgi?id=9987 Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com> |
||
Janusz Kaczmarek
|
4458ac5764 |
Bug 11650: multiplicated authorities after link_bibs_to_authorities.pl
Under certain circumstances misc/link_bibs_to_authorities.pl creates multiple authority with identical heading. Test plan: 1. Have some (2-3) biblio records with some repeated headings Have BiblioAddsAuthorities = allow, AutoCreateAuthorities = generate Have no authority records 2. Run misc/link_bibs_to_authorities.pl script 3. You will get multiple authority records -- one for each occurence of a heading in biblio record. 4. Apply the patch. 5. Repeat 1-3 (remember to have "fresh" biblios, without $9, and no authorities). 6. The problem should be fixed. Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com> Works as described. |
||
Jared Camins-Esakov
|
8a718d6c9b |
Bug 8447: Make sure we have enough subfields for broader_headings
Thanks to wajasu for providing the debugging information, as I cannot seem to duplicate the problem, even seeing where it could come from. Fix corrects cases where upon save, a software error complaing about indicators being wrong as a side effect of a poorly autogenerated biblio/authority record. Behvior with this fix causes existing bilio data to to be preserved while linking to the authority via subtag 9. Signed-off-by: wajasu <matted-34813@mypacks.net> Signed-off-by: Paul Poulain <paul.poulain@biblibre.com> |
||
Jared Camins-Esakov
|
5207699f98 |
signed off Bug 7284: Authority matching improvements
Squashed patch incorporating all previous patches (there is no functional change compared to the previous version of this patch, this patch merely squashes the original patch and follow-up, and rebases on latest master). === TL;DR VERSION === *** Installation *** 1. Run installer/data/mysql/atomicupdate/bug_7284_authority_linking_pt1 and installer/data/mysql/atomicupdate/bug_7284_authority_linking_pt2 2. Make sure you copy the following files from kohaclone to koha-dev: etc/zeradb/authorities/etc/bib1.att, etc/zebradb/marc_defs/marc21/authorities/authority-koha-indexdefs.xml, etc/zebradb/marc_defs/marc21/authorities/authority-zebra-indexdefs.xsl, etc/zebradb/marc_defs/marc21/authorities/koha-indexdefs-to-zebra.xsl, and etc/zebradb/marc_defs/unimarc/authorities/record.abs 3. Run misc/migration_tools/rebuild_zebra.pl -a -r *** New sysprefs *** * AutoCreateAuthorities * CatalogModuleRelink * LinkerModule * LinkerOptions * LinkerRelink * LinkerKeepStale *** Important notes *** You must have rebuild_zebra processing the zebraqueue for bibs when testing this patch. === DESCRIPTION === *** Cataloging module *** * Added an additional box to the authority finder plugin for "Heading match," which consults not just the main entry but also See-from and See-also-from headings. * With this patch, the automatic authority linking will actually work properly in the cataloging module. As Owen pointed out while testing the patch, though, longtime users of Koha will not be expecting that. In keeping with the principles of least surprise and maximum configurability, a new syspref, CatalogModuleRelink makes it possible to disable authority relinking in the cataloging module only (i.e. leaving it enabled for future runs of link_bibs_to_authorities.pl). Note that though the default behavior matches the current behavior of Koha, it does not match the intended behavior. Libraries that want the intended behavior rather than the current behavior will need to adjust the CatalogModuleRelink syspref. *** misc/link_bibs_to_authorities.pl *** Added the following options to the misc/link_bibs_to_authorities.pl script: --auth-limit Only process those headings that match the authorities matching the user-specified WHERE clause. --bib-limit Only process those bib records that match the user-specified WHERE clause. --commit Commit the results to the database after every N records are processed. --link-report Display a report of all the headings that were processed. Converted misc/link_bibs_to_authorities.pl to use POD. Added a detailed report of headings that linked, did not link, and linked in a "fuzzy" fashion (the exact semantics of fuzzy are up to the individual linker modules) during the run. *** C4::Linker *** Implemented new C4::Linker functionality to make it possible to easily add custom authority linker algorithms. Currently available linker options are: * Default: retains the current behavior of only creating links when there is an exact match to one and only one authority record; if the 'broader_headings' option is enabled, it will try to link to headings to authority records for broader headings by removing subfields from the end of the heading (NOTE: test the results before enabling broader_headings in a production system because its usefulness is very much dependent on individual sites' authority files) * First Match: based on Default, creates a link to the *first* authority record that matches a given heading, even if there is more than one authority record that matches * Last Match: based on Default, creates a link to the *last* authority record that matches a given heading, even if there is more than one record that matches The API for linker modules is very simple. All modules should implement the following two functions: <get_link ($field)> - return the authid for the authority that should be linked to the provided MARC::Field object, and a boolean to indicate whether the match is "fuzzy" (the semantics of "fuzzy" are up to the individual plugin). In order to handle authority limits, get_link should always end with: return $self->SUPER::_handle_auth_limit($authid), $fuzzy; <flip_heading ($field)> - return a MARC::Field object with the heading flipped to the preferred form. At present this routine is not used, and can be a stub. Made the linking functionality use the SearchAuthorities in C4::AuthoritiesMarc rather than SimpleSearch in C4::Search. Once C4::Search has been refactored, SearchAuthorities should be rewritten to simply call into C4::Search. However, at this time C4::Search cannot handle authority searching. Also fixed numerous performance issues in SearchAuthorities and the Linker script: * Correctly destroy ZOOM recordsets in SearchAuthorities when finished. If left undestroyed, efficiency appears to approach O(log n^n) * Add an optional $skipmetadata flag to SearchAuthorities that can be used to avoid additional calls into Zebra when all that is wanted are authority records and not statistics about their use *** New sysprefs *** * AutoCreateAuthorities - When this and BiblioAddsAuthorities are both turned on, automatically create authority records for headings that don't have any authority link when cataloging. When BiblioAddsAuthorities is on and AutoCreateAuthorities is turned off, do not automatically generate authority records, but allow the user to enter headings that don't match an existing authority. When BiblioAddsAuthorities is off, this has no effect. * CatalogModuleRelink - when turned on, the automatic linker will relink headings when a record is saved in the cataloging module when LinkerRelink is turned on, even if the headings were manually linked to a different authority by the cataloger. When turned off (the default), the automatic linker will not relink any headings that have already been linked when a record is saved. * LinkerModule - Chooses which linker module to use for matching headings (current options are as described above in the section on linker options: "Default," "FirstMatch," and "LastMatch") * LinkerOptions - A pipe-separated list of options to set for the authority linker (at the moment, the only option available is "broader_headings," which is described below) * LinkerRelink - When turned on, the linker will confirm the links for headings that have previously been linked to an authority record when it runs. When turned off, any heading with an existing link will be ignored. * LinkerKeepStale - When turned on, the linker will never *delete* a link to an authority record, though, depending on the value of LinkerRelink, it may change the link. *** Other changes *** * Cleaned up authorities code by removing unused functions and adding unimplemented functions and added some unit tests. * This patch also modifies the authority indexing to remove trailing punctuation from Match indexes. * Replace the old BiblioAddAuthorities subroutines with calls into the new C4::Linker routines. * Add a simple implementation for C4::Heading::UNIMARC. (With thanks to F. Demians, 2011.01.09) Correct C4::Heading::UNIMARC class loading. Create biblio tag to authority types data structure at initialization rather than querying DB. * Ran perltidy on all changed code. *** Linker Options *** Enter "broader_headings" in LinkerOptions. With this option, the linker will try to match the following heading as follows: =600 10$aCamins-Esakov, Jared$xCoin collections$vCatalogs$vEarly works to 1800. First: Camins-Esakov, Jared--Coin collections--Catalogs--Early works to 1800 Next: Camins-Esakov, Jared--Coin collections--Catalogs Next: Camins-Esakov, Jared--Coin collections Next: Camins-Esakov, Jared (matches! if a previous attempt had matched, it would not have tried this) This is probably relevant only to MARC21 and LCSH, but could potentially be of great use to libraries that make heavy use of floating subdivisions. === TESTING PLAN === Note: all of these tests require that you have some authority records, preferably for headings that actually appear in your bibliographic data. At least one authority record must contain a "see from" reference (remember which one contains this, as you'll need it for some of the tests). The number shown in the "Used in" column in the authority module is populated using Zebra searches of the bibliographic database, so you *must* have rebuild_zebra.pl -b -z [-x] running in cron, or manually run it after running the linker. *** Testing the Heading match in the cataloging plugin *** 1. Create a new record, and open the cataloging plugin for an authority-controlled field. 2. Search for an authority by entering the "see from" term in the Heading Match box 3. Confirm that the appropriate heading shows up 4. Search for an authority by entering the preferred heading into the Main entry or Main entry ($a only) box (i.e., repeat the procedure you usually use for cataloging, whatever that may be) 5. Confirm that the appropriate heading shows up *** Testing the cataloging interface *** 6. Turn off BiblioAddsAuthorities 7. Confirm that you cannot enter text directly in an authority-controlled field 8. Confirm that if you search for a heading using the authority control plugin the heading is inserted (note, however, that this patch does not AND IS NOT INTENDED TO fix the bugs in the authority plugin with duplicate subfields; those are wholly out of scope- this check is for regressions) 9. Turn on BiblioAddsAuthorities and AutoCreateAuthorities 10. Confirm that you can enter text directly into an authority-controlled field, and if you enter a heading that doesn't currently have an authority record, an authority record stub is automatically created, and the heading you entered linked 11. Confirm that if you enter a heading with only a subfield $a that fully *matches* an existing heading (i.e. the existing heading has only subfield $a populated), the authid for that heading is inserted into subfield $9 12. Confirm that if you enter a heading with multiple subfields that *matches* an existing heading, the authid for that heading is inserted into subfield $9 13. Turn on BiblioAddsAuthorities and turn off AutoCreateAuthorities 14. Confirm that you can enter text directly into an authority-controlled field, and if you enter a heading that doesn't currently have an authority record, an authority record stub is *not* created 15. Confirm that if you enter a heading with only a subfield $a that *matches* an existing heading, the authid for that heading is inserted into subfield $9 16. Confirm that if you enter a heading with multiple subfields that *matches* an existing heading, the authid for that heading is inserted into subfield $9 17. Create a record and link an authority record to an authorized field using the authority plugin. 18. Save the record. Ensure that the heading is linked to the appropriate authority. 19. Open the record. Change the heading manually to something else, leaving the link. Save the record. 20. Ensure that the heading remains linked to that same authority. 21. Change CatalogModuleRelink to "on." 22. Open the record. Use the authority plugin to link that heading to the same authority record you did earlier. 23. Save the record. Ensure that the heading is linked to the appropriate authority. 24. Open the record. Change the heading manually to something else, leaving the link. Save the record. 25. Ensure that the heading is no longer linked to the old authority record. *** Testing link_bibs_to_authorities.pl *** 26. Set LinkerModule to "Default," turn on LinkerRelink and BiblioAddsAuthorities, and turn AutoCreateAuthorities and LinkerKeepStale off 27. Edit one bib record so that an authority controlled field that has already been linked (i.e. has data in $9) has a heading that does not match any authority record in your database 28. Run misc/link_bibs_to_authorities.pl --link-report --verbose --test (you may want to pipe the output into less or a file, as the result is quite a lot of information) 29. Look over the report to see if the headings that you have authority records for report being matched, that the heading you modified in step 2 is reported as "unlinked," and confirm that no changes were actually made to the database (to check this, look at the bib record you edited earlier, and check that the authid in the field you edited hasn't changed) 30. Run misc/link_bibs_to_authorities.pl --link-report --verbose (you may want to pipe the output into less or a file, as the result is quite a lot of information) 31. Check that the heading you modified has been unlinked 32. Change the modified heading back to whatever it was, but don't use the authority control plugin to populate $9 33. Run misc/link_bibs_to_authorities.pl --link-report --verbose --bib-limit="biblionumber=${BIB}" (replacing ${BIB} with the biblionumber of the record you've been editing) 34. Confirm that the heading has been linked to the correct authority record 35. Turn LinkerKeepStale on 36. Change that heading to something else 37. Run misc/link_bibs_to_authorities.pl --link-report --verbose --bib-limit="biblionumber=${BIB}" (replacing ${BIB} with the biblionumber of the record you've been editing) 38. Confirm that the $9 has not changed 39. Turn LinkerKeepStale off 40. Create two authorities with the same heading 41. Run misc/migration_tools/rebuild_zebra.pl -a -z 42. Enter that heading into the bibliographic record you are working with 43. Run misc/link_bibs_to_authorities.pl --link-report --verbose --bib-limit="biblionumber=${BIB}" (replacing ${BIB} with the biblionumber of the record you've been editing) 44. Confirm that the heading has not been linked 45. Change LinkerModule to "FirstMatch" 46. Run misc/link_bibs_to_authorities.pl --link-report --verbose --bib-limit="biblionumber=${BIB}" (replacing ${BIB} with the biblionumber of the record you've been editing) 47. Confirm that the heading has been linked to the first authority record it matches 48. Change LinkerModule to "LastMatch" 49. Run misc/link_bibs_to_authorities.pl --link-report --verbose --bib-limit="biblionumber=${BIB}" (replacing ${BIB} with the biblionumber of the record you've been editing) 50. Confirm that the heading has been linked to the second authority record it matches 51. Run misc/link_bibs_to_authorities.pl --link-report --verbose --auth-limit="authid=${AUTH}" (replacing ${AUTH} with an authid) 52. Confirm that only that heading is displayed in the report, and only those bibs with that heading have been changed If all those things worked, good news! You're ready to sign off on the patch for bug 7284. Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> Rebased on latest master and squashed follow-up, 16 February 2012 Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> Rebased on latest master, 21 February 2012 Signed-off-by: schuster <dschust1@gmail.com> |