Bug 14332 - Skip title articles on Opac using ind2 of tag 245 (MARC21 only)
Summary: Skip title articles on Opac using ind2 of tag 245 (MARC21 only)
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Zeno Tajoli
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 18540
  Show dependency treegraph
 
Reported: 2015-06-04 15:11 UTC by Zeno Tajoli
Modified: 2019-09-22 20:52 UTC (History)
5 users (show)

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


Attachments
skip article (only marc21) (6.40 KB, patch)
2015-06-04 15:43 UTC, Zeno Tajoli
Details | Diff | Splinter Review
One MARC21 biblio record to test the patch (561 bytes, application/xml)
2015-11-11 14:53 UTC, Frédéric Demians
Details
Skip articles in MARC21 using indicator n.2 of field 245 (6.94 KB, patch)
2015-11-11 14:59 UTC, Frédéric Demians
Details | Diff | Splinter Review
Skip articles in MARC21 using indicator n.2 of field 245 (7.18 KB, patch)
2016-01-06 00:21 UTC, Jesse Weaver
Details | Diff | Splinter Review
Bug 14332: Skip articles in MARC21 using indicator n.2 of field 245 (7.14 KB, patch)
2016-01-06 00:22 UTC, Jesse Weaver
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Zeno Tajoli 2015-06-04 15:11:54 UTC
With specific setup of Zebra is possible to skip articles of titles only on sorting.
In MARC21 we can use indicator n. 2 of field 245.

There suggestion from indexdata here:
http://www.indexdata.com/zebra/doc/record-model-domxml-conf.html
Comment 1 Zeno Tajoli 2015-06-04 15:43:01 UTC Comment hidden (obsolete)
Comment 2 Zeno Tajoli 2015-06-04 15:43:36 UTC
My proposal to fix the problem
Comment 3 Frédéric Demians 2015-11-11 14:53:12 UTC
Created attachment 44768 [details]
One MARC21 biblio record to test the patch
Comment 4 Frédéric Demians 2015-11-11 14:59:35 UTC Comment hidden (obsolete)
Comment 5 Jesse Weaver 2016-01-06 00:21:49 UTC Comment hidden (obsolete)
Comment 6 Jesse Weaver 2016-01-06 00:22:38 UTC
Created attachment 46288 [details] [review]
Bug 14332: Skip articles in MARC21 using indicator n.2 of field 245

Only in MARC21 is possible to use ind2 of tag 245 to skip articles.
This patch is based on inserting a special template in
koha-indexdefs-to-zebra.xsl With this patch you must not insert index
Title:s in biblio-koha-indexdefs.xml, it is defined in
koha-indexdefs-to-zebra.xsl.  It is not the best setup, but I find very
difficult  to use  biblio-koha-indexdefs.xml.

To test it in a english MARC21 setup:

Insert same records with titles and correct values in ind2 of 245.
If you have articles not in the skiping list of sort-string-utf.chr (The|the|a|A|an|An)
you can see that the sort by articles use also articles.

Insert the patch
Rebuilt indexes from scratch

Now all articles of titles are skipped

TO TEST WITHOUT INDEXING:

1. Go to etc/zebradb/marc_defs/marc21/biblios directory.

2. Put the sample MARCXML file in this directory.

3. Transform the file into Zebra indexes:
   xsltproc biblio-zebra-indexdefs.xsl record.xml
   Observe that the Title:s index contains:
   01 Business and Technologies

4. Apply the patch.

5. Repeat:
   xsltproc biblio-zebra-indexdefs.xsl record.xml
   Observe that the Title:s index contains:
   Business and Technologies

Signed-off-by: Frederic Demians <f.demians@tamil.fr>

Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
Verified working using yaz-client (as in
http://wiki.koha-community.org/wiki/Understanding_Zebra_indexing#Examine_Zebra_index,
though note that the `elem zebra::index` seems to be unneeded).

(Updated commit message to include bug number.)
Comment 7 Brendan Gallagher 2016-01-27 06:18:15 UTC
Pushed to Master - Should be in the May 2016 release.  Thanks!
Comment 8 Tomás Cohen Arazi 2016-12-02 20:13:34 UTC
This implementation is causing some troubles because the koha-indexdefs-to-zebra.xsl is by no means MARC21-only or even biblio-only.

To reproduce:
- On current master, run:
  $ xsltproc etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl etc/zebradb/marc_defs/unimarc/biblios/biblio-koha-indexdefs.xml > etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl
- Run:
  $ git diff
=> FAIL: The following is added to etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl, thus UNIMARC field 245 is being sent to the Title index

@@ -42,6 +43,7 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml)
       <xslo:apply-templates mode="index_match_heading"/>
       <xslo:apply-templates mode="index_subject_thesaurus"/>
       <xslo:apply-templates mode="index_all"/>
+      <xslo:apply-templates mode="index_sort_tit"/>
     </z:record>
   </xslo:template>
   <xslo:template match="marc:controlfield[@tag='001']">
@@ -2681,6 +2683,19 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml)
       <xslo:value-of select="."/>
     </z:index>
   </xslo:template>
+  <xslo:template mode="index_sort_tit" match="marc:datafield[@tag='245']">
+    <xslo:variable name="chop">
+      <xslo:choose>
+        <xslo:when test="not(number(@ind2))">0</xslo:when>
+        <xslo:otherwise>
+          <xslo:value-of select="number(@ind2)"/>
+        </xslo:otherwise>
+      </xslo:choose>
+    </xslo:variable>
+    <z:index name="Title:s">
+      <xslo:value-of select="substring(marc:subfield[@code='a'], $chop+1)"/>
+    </z:index>
+  </xslo:template>
Comment 9 Katrin Fischer 2019-09-22 20:52:32 UTC
(In reply to Tomás Cohen Arazi from comment #8)
> This implementation is causing some troubles because the
> koha-indexdefs-to-zebra.xsl is by no means MARC21-only or even biblio-only.
> 
> To reproduce:
> - On current master, run:
>   $ xsltproc etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl
> etc/zebradb/marc_defs/unimarc/biblios/biblio-koha-indexdefs.xml >
> etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl
> - Run:
>   $ git diff
> => FAIL: The following is added to
> etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl, thus
> UNIMARC field 245 is being sent to the Title index
> 
> @@ -42,6 +43,7 @@ definition file (probably something like
> {biblio,authority}-koha-indexdefs.xml)
>        <xslo:apply-templates mode="index_match_heading"/>
>        <xslo:apply-templates mode="index_subject_thesaurus"/>
>        <xslo:apply-templates mode="index_all"/>
> +      <xslo:apply-templates mode="index_sort_tit"/>
>      </z:record>
>    </xslo:template>
>    <xslo:template match="marc:controlfield[@tag='001']">
> @@ -2681,6 +2683,19 @@ definition file (probably something like
> {biblio,authority}-koha-indexdefs.xml)
>        <xslo:value-of select="."/>
>      </z:index>
>    </xslo:template>
> +  <xslo:template mode="index_sort_tit" match="marc:datafield[@tag='245']">
> +    <xslo:variable name="chop">
> +      <xslo:choose>
> +        <xslo:when test="not(number(@ind2))">0</xslo:when>
> +        <xslo:otherwise>
> +          <xslo:value-of select="number(@ind2)"/>
> +        </xslo:otherwise>
> +      </xslo:choose>
> +    </xslo:variable>
> +    <z:index name="Title:s">
> +      <xslo:value-of select="substring(marc:subfield[@code='a'], $chop+1)"/>
> +    </z:index>
> +  </xslo:template>

Should this be filed as a new bug? I think it has been missed here?