How to add new zebra index

From Koha Wiki
Jump to navigation Jump to search

How to Add new MARC fields to Zebra indexes

I searched a lot for direct way to add new field to be searchable with zebra with no luck, so I thought it will be good idea to make one.

Let's do it together step by step.

Step 1

Step 2

  • In the file /etc/koha/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml add the following lines:
 <index_data_field tag="596" subfields="a">
   <target_index>Note596a:w</target_index>
 </index_data_field>

Note

Step 3

  • In the file /etc/koha/zebradb/biblios/etc/bib1.att add the following line:
 att 65    Note596a

Note

The attribute number (65 in this example) can be selected from the Bib-1 attribute set (see http://www.loc.gov/z3950/agency/defns/bib1.html#use ) or a new attribute number can be made up.

Note596a is the index name.

Step 4

  • In the file /etc/koha/zebradb/ccl.properties add the following line:
 Note596a 1=65

Note

Note596a is the index name.

1=65 is the CCL mapping.

Step 5

  • Run the following command, you might need to adjust the paths to match those in your installation
 xsltproc /etc/koha/zebradb/xsl/koha-indexdefs-to-zebra.xsl /etc/koha/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml > /etc/koha/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl

xsltproc is a command line XSLT processor. This will overwrite biblio-zebra-indexdefs.xsl with your modified biblio-koha-indexdefs.xml using koha-indexdefs-to-zebra.xsl.

Step 6

  • Run the following command
 sudo koha-rebuild-zebra -b -f -v <yourInstance>


Step 7

  • To add the new index in indexes select list in staff search go to
 /usr/share/koha/intranet/htdocs/intranet-tmpl/prog/en/includes/
  • Edit search_indexes.inc and add
 <option value="Note596a">Find the first manuscript</option>

before

</select>

Step 8

  • To add the new index in indexes select list in OPAC search go to
 /usr/share/koha/opac/htdocs/opac-tmpl/prog/en/modules

or, in more recent versions, e.g. 20.n:

 /usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/<lng>/modules, e.g.
 /usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/modules
  • Edit opac-advsearch.tt and add
 <option value="Note596a">Search the first manuscript</option> before </select>

Step 9

  • To add the new index to Refine your search menu go to
 /usr/share/koha/lib/C4/
  • Edit koha.pm go to sub getFacets add the following
 {
   idx   => 'Note596a',
   label => 'first of mono',
   tags  => [ qw/ 596a / ],
   sep   => ', ',
 },

Note

You'll also need to change the corresponding template file to make the new facet visible in OPAC and/or the staff interface.

Step 10

  • In order for the index to be searchable when using CQL and maybe in general, you also need to add it to the list of indexes in Search.pm.
sub getIndexes{
    my @indexes = (
                    # biblio indexes
                    'ab',
                    'Abstract',
                    'acqdate',
                    'allrecords',
                    ...
                    'Note596',

See also

Credits

Special thanks for the Institute of Arabic manuscripts to support these steps And also for Dr. Ahmed Abdalradi

I Hope to be useful for all Ashraf Brzy IT manager Heliopolis University --Ashraf.brzy 15:29, 15 February 2013 (EST)

It has been very helpful for us! Thank you dear Sir! --Olli-Antti Kivilahti, www.vaarakirjastot.fi