<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-AU link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Hey all:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I was just adding an alternate patch for <a href="http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14861">http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14861</a>, and I started thinking a bit about date indexes in Zebra… and how we’re not using them as effectively as we could.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>For MARC21, we only actually have one date index and that’s for “Date-of-acquisition”, even though we store lots of other ISO-formatted dates such as "datelastseen”, "replacementpricedate”, “datelastborrowed”. Technically “Date/time-last-modified” is in ISO format, although we’d have to test how Zebra handles the time element of the string… and we might want to transform it into the extended ISO format (e.g. YYYY-MM-DD hh:mm:ss) which is used elsewhere. “date-entered-on-file” could also be transformed although it has the Y2K issue.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>That said, I don’t think these fields are particularly popular. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I noticed that UNIMARC indexes “items.onloan” which MARC21 refers to as 952$q. That might be an interesting one. UNIMARC indexes that as a “date index”. Provided that the indexes are up-to-date, you could quickly search for all records with items due on a particular date… and after bug 14861 is pushed… you could also search for date ranges. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Anyway, just a thought. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I’m not sure how many people are familiar with ccl.properties, biblio-zebra-indexdefs.xsl, bib1.att, default.idx, and the rest of the Zebra configuration files, but I’ve included an explanation at the end of this file regarding the MARC21 Zebra configuration.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>--<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>Bib1.att defines mappings between numbers and index names. The index names are used both during indexing (and optionally during searching/retrieval). The numbers are used just for searching/retrieval. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>For example:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>att 4    Title<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>ccl.properties creates mappings between user-defined “CCL qualifiers” and the Bib1.att “use” attribute numbers. It also can create additional aliases for “CCL qualifiers”.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>For example:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Title 1=4<o:p></o:p></p><p class=MsoNormal>ti Title<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>In this case, “Title” is the “CCL qualifier” and “ti” is an alias for “Title”. 1 stands for “Use attribute” and 4 stands for “att 4” from Bib1.att.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>biblio-zebra-indexdefs.xsl parses MARCXML records and transforms them into a format that Zebra uses for indexing. It uses the “index names” from the Bib1.att file for this purpose. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Here’s a snippet from that file for MARC21:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>  <xslo:template mode="index_subfields" match="marc:datafield[@tag='245']"><o:p></o:p></p><p class=MsoNormal>    <xslo:for-each select="marc:subfield"><o:p></o:p></p><p class=MsoNormal>      <xslo:if test="contains('a', @code)"><o:p></o:p></p><p class=MsoNormal>        <z:index name="Title-cover:w Title-cover:p Title-cover:s Title:w Title:p Title:s"><o:p></o:p></p><p class=MsoNormal>          <xslo:value-of select="."/><o:p></o:p></p><p class=MsoNormal>        </z:index><o:p></o:p></p><p class=MsoNormal>      </xslo:if><o:p></o:p></p><p class=MsoNormal>    </xslo:for-each><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>As we can see, field ‘245’ subfield ‘a’ gets stored in the “Title-cover” and “Title” indexes. But they also have those “:w”, “:p”, and “:s” bits added. Those refer to “register types”.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>“w” is the word register, “p” is the phrase register, and “s” is the sort register. There are others which you can find in “default.idx”. There others include “n” for numeric, “d” for date, and “y” for year. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>These “registers” are mapped to Bib-1 “Structure” attributes. These mappings can be found at <a href="http://www.indexdata.com/zebra/doc/querymodel-zebra.html#querymodel-pqf-apt-mapping">http://www.indexdata.com/zebra/doc/querymodel-zebra.html#querymodel-pqf-apt-mapping</a>.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>So if you want to search the “date” register for a particular index, you’ll need to form a CCL query that uses “st-date-normalized” since it’s mapped to “4=5” (ie structure attribute number 5), since this is the structure that is mapped  to the “date” register in Zebra. Typically, the default structure in Zebra is “phrase”, although Koha uses some query building “magic” to often use the “word-list” structure, which is mapped to both the “word” and “phrase” registers. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thus, “acqdate, st-date-normalized = 2015-09-01” will search the “Date-of-acquisition” index (since “acqdate” is just an alias for the “Date-of-acquisition CCL qualifier which is mapped to the “Date-of-acquisition” index, and st-date-normalized is mapped to the “date” register).<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The patch for 14861 will also make it so that you can search ISO date ranges such as: “acqdate, st-date-normalized = 2015-09-01 - 2015-09-30” or “acqdate, st-date-normalized = 2014 - 2015” or even “acqdate, st-date-normalized = 2014-01 - 2014-03” . Note that the whitespace between the digital and the hyphen are significant.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>For more fun with Zebra, consider reading some of the content at <a href="http://wiki.koha-community.org/wiki/Troubleshooting_Zebra">http://wiki.koha-community.org/wiki/Troubleshooting_Zebra</a>.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='mso-fareast-language:EN-AU'>David Cook<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-AU'>Systems Librarian<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-AU'>Prosentient Systems<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-AU'>72/330 Wattle St, Ultimo, NSW 2007<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>