Bug 36852 - Enhance Elasticsearch subject, subject as phrase MARC21 index mappings
Summary: Enhance Elasticsearch subject, subject as phrase MARC21 index mappings
Status: In Discussion
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Elasticsearch (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Wainui Witika-Park
QA Contact: Thomas Klausner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-13 23:34 UTC by Aleisha Amohia
Modified: 2024-09-13 06:18 UTC (History)
5 users (show)

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


Attachments
Bug 36852: Enhance Elasticsearch subject, subject as phrase MARC21 index mappings (1.75 KB, patch)
2024-05-30 01:24 UTC, Wainui Witika-Park
Details | Diff | Splinter Review
Bug 36852: Enhance Elasticsearch subject, subject as phrase MARC21 index mappings (1.79 KB, patch)
2024-05-31 04:39 UTC, David Nind
Details | Diff | Splinter Review
Bug 36852: Enhance Elasticsearch subject, subject as phrase MARC21 index mappings (1.84 KB, patch)
2024-07-16 19:46 UTC, Thomas Klausner
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Aleisha Amohia 2024-05-13 23:34:27 UTC
We would like to add the following tags and subfields to the existing subject index for Elasticsearch MARC21, as used by the "subject" and "subject as phrase" advanced search dropdown options:

* 600abc (currently 600a)
* 610abcdnty (currently 610a and 610t)
* 630amnoprsxyz (currently 630n and 630r)

Explanation to justify these mappings:

* To search subject added entry, personal name ($600), numeration ($b) and titles and other words associated with name ($c).
e.g. 600 $a Elizabeth $n I $c Queen of England.

* To search subject added entry, corporate name (610), subordinate unit ($b), location of meeting ($c), date of meeting ($d), number of part/section of meeting ($n), title of a work ($t) and chronological subdivision ($y)
e.g. 610 $a International Labour Organisation $b European Regional Conference $n (2nd :$d 1968 :$c Geneva, Switzerland). 
e.g. 610 $a France. $t Constitution.
e.g. 610 $a United States $b Army $b Cavalry History $y Civil War, 1861-1865.

* To search subject added entry, uniform title (630 $a), number of part/section of a work($n), name of part/section of work ($p), general subdivision ($x), chronological subdivision ($y), geographical subdivision ($z). 

* Also, search subject added entry, uniform title (630), for medium of performance for music ($m), arranged statement of music ($o), key for music ($r) and version ($s).
Comment 1 Wainui Witika-Park 2024-05-30 01:24:46 UTC
Created attachment 167252 [details] [review]
Bug 36852: Enhance Elasticsearch subject, subject as phrase MARC21 index mappings

Add the following tags and subfields to the existing subject index for Elasticsearch MARC21, as used by the "subject" and "subject as phrase" advanced search dropdown options: 600abc (currently 600a), 610abcdnty (currently 610a and 610t), 630amnoprsxyz (currently 630n and 630r)

Sponsored-by: Educational Services Australia SCIS
Comment 2 David Nind 2024-05-31 04:39:01 UTC
Created attachment 167299 [details] [review]
Bug 36852: Enhance Elasticsearch subject, subject as phrase MARC21 index mappings

Add the following tags and subfields to the existing subject index for Elasticsearch MARC21, as used by the "subject" and "subject as phrase" advanced search dropdown options: 600abc (currently 600a), 610abcdnty (currently 610a and 610t), 630amnoprsxyz (currently 630n and 630r)

Sponsored-by: Educational Services Australia SCIS
Signed-off-by: David Nind <david@davidnind.com>
Comment 3 David Nind 2024-05-31 04:39:25 UTC
Testing notes using KTD:

1. Start up KTD with Elasticsearch: ktd --es8 up

2. Edit a record and add unique values as follows (I edited Programming Perl, 262):
   . 600 $a Elizabeth $b IV $c Queen of England.
   . 610 $a International Labour Organisation $b European Regional Conference $n (2nd :$d 1968 :$c Geneva, Switzerland). 
   . 630 $a Ukrainian weekly $n XXI $r C sharp $s 2024 $vIndexes $vPeriodicals.
   . Note: Need to edit BKS framework to make  610n and 630mnoprs subfields visible in the editor for KTD)
   Mappings - current and changes:
   * 600a => 600abc
   * 610a and 610t => 610abcdnty
   * 630n and 630r=> 630amnoprsxyz

3. Do a search for the terms in the subfields not currently using the 'Subject' and 'Subject as a phrase' indexes in the staff interface advanced search.
   ==> Result: Should get a result when using values in the subfields that are mapped, but no result where the subfields are not mapped.

4. Apply this patch and restart all services (restart_all).

5. Reset the mappings: Administration > Catalog > Search engine configuration (Elasticsearch) > Reset mappings (at the bottom of the page)

6. Reindex: koha-elasticsearch --rebuild -d -b -a kohadev

7. Alternative to steps 5 and 6: reset_all then repeat step 2

8. Repeat step 3
   ==> Result: Should now get a result when using values in the subfields that are now mapped (that weren't previously).
Comment 4 Thomas Klausner 2024-07-16 19:46:16 UTC
Created attachment 169066 [details] [review]
Bug 36852: Enhance Elasticsearch subject, subject as phrase MARC21 index mappings

Add the following tags and subfields to the existing subject index for Elasticsearch MARC21, as used by the "subject" and "subject as phrase" advanced search dropdown options: 600abc (currently 600a), 610abcdnty (currently 610a and 610t), 630amnoprsxyz (currently 630n and 630r)

Sponsored-by: Educational Services Australia SCIS
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Thomas Klausner <domm@plix.at>
Comment 5 David Cook 2024-07-17 00:02:34 UTC
Same issue as bug #36850
Comment 6 Olli-Antti Kivilahti 2024-09-13 06:18:08 UTC
Hi!
We have a client who has a similar-but-opposite problem regarding subject searching.
When looking for a specific "subject as phrase", Koha returns also more general subjects.

eg.

su,phr:"Europe"

returns: "Europe", "European brotherhood", "European ancestry"

If we were to add 610$b "European Regional Conference" to subject-index, su,phr:"Europe" would also return the record with a mention of the conference.
Which might not be desirable.

My point:
- Presently, if this change is accepted, it would exaggerate our client's search challenge.
- The change is good, when the way the subject-index phrase search is tokenized in the ES search index, is changed:
-- "subject as phrase"-search needs to use it's own search index,
   'subject-phrase'.
-- 'subject-phrase' needs to follow its own rules of search term tokenization.
   This is achieved using a Elastic field-specific analyzer.
--- It must preserve the way the words are written exactly within a subfield.
    So tokenize the complete subject word/words as a single indexed search
    token.
    eg. 610$a "International Labour Organisation" is tokenized to index as
    "International Labour Organisation"
    instead of the current way:
    "International", "Labour", "Organisation"
--- Rewire the advancedsearch to use the new 'subject-phrase'-index