Summary: | Add "subject (broader)," "subject (narrower)," and "subject (related)" options for search | ||
---|---|---|---|
Product: | Koha | Reporter: | Jared Camins-Esakov <jcamins> |
Component: | Searching | Assignee: | Jared Camins-Esakov <jcamins> |
Status: | CLOSED FIXED | QA Contact: | Jonathan Druart <jonathan.druart> |
Severity: | enhancement | ||
Priority: | P5 - low | CC: | jonathan.druart, matted-34813, paul.poulain |
Version: | 3.10 | ||
Hardware: | All | ||
OS: | All | ||
GIT URL: | Change sponsored?: | Sponsored | |
Patch complexity: | --- | Documentation contact: | |
Documentation submission: | Text to go in the release notes: | ||
Version(s) released in: | Circulation function: | ||
Bug Depends on: | 7818, 8649, 8744 | ||
Bug Blocks: | 8212, 8726 | ||
Attachments: |
Bug 8211: Add exploded search options
Bug 8211: Add exploded search options Bug 8211: Add exploded search options SIGNED-OFF-Bug-8211-Add-exploded-search-options.patch |
Description
Jared Camins-Esakov
2012-06-07 14:50:16 UTC
Created attachment 11851 [details] [review] Bug 8211: Add exploded search options When working with hierarchical subject headings, it is sometimes helpful to do a search for all records with a specific subject, plus broader/narrower/related subjects. This patch adds support for these "exploded" subject searches to Koha. To test: 1) Make sure you have a bunch of hierarchical subjects. I created geographical subjects for "Arizona," "United States," and "Phoenix," and linked them together using 551s, and made sure I had a half dozen records linking to each (but not all to all three). 2) Do a search for su-br:Arizona (or choose "Subject and broader terms" on the advanced search screen with "more options" displayed), and check that you get the records with the subject "Arizona" and the records with the subject "United States" 3) Do a search for su-na:Arizona (or choose "Subject and narrower terms" on the advanced search screen with "more options" displayed), and check that you get the records with the subject "Arizona" and the records with the subject "Phoenix" 4) Do a search for su-rl:Arizona (or choose "Subject and related terms" on the advanced search screen with "more options" displayed), and check that you get the records with the subject "Arizona," the records with the subject "United States," and the records with the subject "Phoenix" 5) Ensure that other searches still work (keyword, subject, ccl, whatever) 6) Sign off Technical details: This patch adds a shim in front of C4::Search::buildQuery in order to preprocess the query and call the _handle_exploding_search callback. This shim will allow us to gradually offload query parsing to a new query parser module. Example authority records: Record 1: =001 1 =151 ##$aArizona. =551 ##$aUnited States$wg$92 =551 ##$aPhoenix$wh$93 Record 2: =001 2 =151 ##$aUnited States. =551 ##$aArizona$wh$91 Record 3: =001 3 =151 ##$aPhoenix. =551 ##$aArizona$wg$91 Created attachment 12090 [details] [review] Bug 8211: Add exploded search options When working with hierarchical subject headings, it is sometimes helpful to do a search for all records with a specific subject, plus broader/narrower/related subjects. This patch adds support for these "exploded" subject searches to Koha. To test: 1) Make sure you have a bunch of hierarchical subjects. I created geographical subjects for "Arizona," "United States," and "Phoenix," and linked them together using 551s, and made sure I had a half dozen records linking to each (but not all to all three). 2) Do a search for su-br:Arizona (or choose "Subject and broader terms" on the advanced search screen with "more options" displayed), and check that you get the records with the subject "Arizona" and the records with the subject "United States" 3) Do a search for su-na:Arizona (or choose "Subject and narrower terms" on the advanced search screen with "more options" displayed), and check that you get the records with the subject "Arizona" and the records with the subject "Phoenix" 4) Do a search for su-rl:Arizona (or choose "Subject and related terms" on the advanced search screen with "more options" displayed), and check that you get the records with the subject "Arizona," the records with the subject "United States," and the records with the subject "Phoenix" 5) Ensure that other searches still work (keyword, subject, ccl, whatever) 6) Sign off Technical details: This patch adds a shim in front of C4::Search::buildQuery in order to preprocess the query and call the _handle_exploding_search callback. This shim will allow us to gradually offload query parsing to a new query parser module. Created attachment 12093 [details] [review] Bug 8211: Add exploded search options When working with hierarchical subject headings, it is sometimes helpful to do a search for all records with a specific subject, plus broader/narrower/related subjects. This patch adds support for these "exploded" subject searches to Koha. To test: 1) Make sure you have a bunch of hierarchical subjects. I created geographical subjects for "Arizona," "United States," and "Phoenix," and linked them together using 551s, and made sure I had a half dozen records linking to each (but not all to all three). 2) Do a search for su-br:Arizona (or choose "Subject and broader terms" on the advanced search screen with "more options" displayed), and check that you get the records with the subject "Arizona" and the records with the subject "United States" 3) Do a search for su-na:Arizona (or choose "Subject and narrower terms" on the advanced search screen with "more options" displayed), and check that you get the records with the subject "Arizona" and the records with the subject "Phoenix" 4) Do a search for su-rl:Arizona (or choose "Subject and related terms" on the advanced search screen with "more options" displayed), and check that you get the records with the subject "Arizona," the records with the subject "United States," and the records with the subject "Phoenix" 5) Ensure that other searches still work (keyword, subject, ccl, whatever) 6) Sign off Technical details: This patch adds a shim in front of C4::Search::buildQuery in order to preprocess the query and call the _handle_exploding_search callback. This shim will allow us to gradually offload query parsing to a new query parser module. Created attachment 12094 [details] [review] SIGNED-OFF-Bug-8211-Add-exploded-search-options.patch After pulling master i applied these: 0001-Bug-8744-Thesaurus-in-authorities-should-not-lock-fi.patch 0002-Bug-8649-Add-unit-test-for-C4-Search.patch 0003-bug-8649-make-sure-C4-Context-is-fully-mocked-up-bef.patch 0004-bug-8649-make-sure-we-can-exit-if-a-test-fails.patch 0005-bug-8649-create-a-temp-directory-for-Zebra-for-C4-Se.patch 0006-bug-8649-quiet-a-variable-use-warning.patch 0007-Bug-8211-Add-exploded-search-options.patch You need 8744 to be able to edit Geographical names in 551 (unlock them) 8649 has Search.t tests 1) I had created the authority heirarchy as comment#2 described. 2) I used z3950 to search LOC specifiying "United States" in subject heading, and chose "1000 things to love about America" and added an item. I navigated to its 651 Geographic name heading and clicked the editor icon for the 'a' subtag, and used the authority search plugin ( $a = United States ) and found the record that was created in step #1). choose it. I finished out the biblio and added an item. 3) I did the same thing as step 2) but for "Arizona" and "Phoenix" subject headingg, linking with the authority plugin as well. Pick a book for Arizona accordingly. 4) I ran rebuild-zebra and did my searches as described in comment #3) in the OPAC search. su-br:Arizona su-na:Arizona and su-rl:Arizona Each returned results. For me: I also had Phoenix in the su-br-Arizona search, and jcamins said there must be a subject heading in my chosen biblio for Phoenix. There was, so I edited my biblio, to remove the Restaurant -- Arizona TOPICAL TERM SUBJECT HEADING. After that I requeried su-br: Arizona, and the Phoenix item did not show up as we wanted. So there is an added restriction to be sure other subject heading don't interfere with results. Cool beans!!! wajasu QA Comments: Looks good to me. Code clean, UT++ Just one thing: maybe it would be better to pass a hashref to parseQuery instead of 7 arguments. But it is possible to have some disagreements about that. Marked as Passed QA. (In reply to comment #6) > QA Comments: > > Looks good to me. > Code clean, UT++ > > Just one thing: maybe it would be better to pass a hashref to parseQuery > instead of 7 arguments. But it is possible to have some disagreements about > that. The reasoning behind using the 7 arguments is that parseQuery is still just a shim, so we want it to look as much like buildQuery as possible. When parseQuery replaces buildQuery, the API will also be changed. Patch pushed to master I had some trouble making this patch work, but, at the end, if your datas are OK and your zebra index uptodate, this patch works like a charm in UNIMARC. This feature is available in Master. |