Main Koha release repository https://koha-community.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

407 lines
20 KiB

[% USE raw %]
[% USE Asset %]
[% PROCESS 'i18n.inc' %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Administration &rsaquo; Search engine configuration</title>
[% INCLUDE 'doc-head-close.inc' %]
[% Asset.js("lib/jquery/plugins/jquery.tablednd.js") | $raw %]
<script>
function clean_line( line ) {
$(line).find('input[type="text"]').val("");
$(line).find('select').find('option:first').attr("selected", "selected");
}
function clone_line( line ) {
var new_line = $(line).clone();
$(new_line).removeClass("nodrag nodrop");
$(new_line).find('td:last-child>a').removeClass("add").addClass("delete").html(_("Delete"));
$(new_line).find('[data-id]').each( function() {
$(this).attr({ name: $(this).attr('data-id') }).removeAttr('data-id');
} );
$(new_line).find("select").each( function() {
var attr = $(this).attr('name');
var val = $(line).find('[data-id="' + attr + '"]').val();
$(this).find('option[value="' + val + '"]').attr("selected", "selected");
} );
return new_line;
}
$(document).ready(function() {
$("#tabs").tabs();
$('.delete').click(function() {
$(this).parents('tr').remove();
});
$("table.mappings").tableDnD( {
onDragClass: "dragClass",
} );
$('.add').click(function() {
var table = $(this).closest('table');
var index_name = $(table).attr('data-index_name');
var line = $(this).closest("tr");
var marc_field = $(line).find('input[data-id="mapping_marc_field"]').val();
if ( marc_field.length > 0 ) {
var new_line = clone_line( line );
new_line.appendTo($('table[data-index_name="'+index_name+'"]>tbody'));
$('.delete').click(function() {
$(this).parents('tr').remove();
});
clean_line(line);
$(table).tableDnD( {
onDragClass: "dragClass",
} );
}
});
$("#facet_biblios > table").tableDnD( {
onDragClass: "dragClass",
} );
});
</script>
<style>
a.add, a.delete {
cursor: pointer;
}
</style>
</head>
<body id="admin_searchengine_mappings" class="admin">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'prefs-admin-search.inc' %]
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; Search engine configuration</div>
<div class="main container-fluid">
<div class="row">
<div class="col-sm-10 col-sm-push-2">
<main>
[% FOR m IN messages %]
<div class="dialog [% m.type | html %]">
[% SWITCH m.code %]
[% CASE 'error_on_update' %]
[% tx("An error occurred when updating mappings: {message}.", { message = m.message }) | html %]
[% CASE 'error_on_delete' %]
[% t("An error occurred when deleting the existing mappings. Nothing has been changed!") | $raw %]
[% tx("(search field {field_name} with mapping {marc_field}.)", { field_name = m.values.field_name, marc_field = m.values.marc_field }) | html %]
[% CASE 'invalid_field_weight' %]
[% tx("Invalid field weight '{weight}', must be a positive decimal number.", { weight = m.weight }) | html %]
[% CASE 'error_on_update_es_mappings' %]
[% tx("An error occurred when updating Elasticsearch index mappings: {message}.", { message = m.message }) | html %]
[% CASE 'reindex_required' %]
[% tx("Index '{index}' needs to be reindexed.", { index = m.index }) | html %]
[% CASE 'recreate_required' %]
[% tx("Index '{index}' needs to be recreated.", { index = m.index }) | html %]
[% CASE 'success_on_update' %]
[% t("Mappings updated successfully.") | $raw %]
[% CASE 'success_on_reset' %]
[% t("Mappings have been reset successfully.") | $raw %]
[% CASE %]
[% m.code | html %]
[% END %]
</div>
[% END %]
<h1>Search engine configuration</h1>
<div class="dialog message">
Warning: Any changes to the configuration will only take effect after a full reindex. Until then searching may not work correctly.
<p>Weight: define weight as a positive number. Higher numbers indicate increased relevancy.
<strong>Note that fields weighting works only for simple search.</strong></p>
<ol>
<li>only search fields mapped with biblios can be weighted</li>
<li>search will boost/increase weighted field(s) relevancy</li>
</ol>
</div>
[% IF errors %]
<div class="dialog alert">
Changes have not been applied. Please check the following values:
<ul>
[% FOREACH e IN errors %]
<li>
[% IF ( e.type == "malformed_mapping" ) %]
<span>The value "[% e.value | html %]" is not supported for mappings</span>
[% ELSIF ( e.type == "no_mapping" ) %]
<span>There is no mapping for the index [% e.value | html %]</span>
[% END %]
</li>
[% END %]
</ul>
</div>
[% END %]
[% IF reset_confirm %]
<div class="dialog alert">
<h3>The current mappings you see on the screen will be erased and replaced by the mappings in the mappings.yaml file.</h3>
<form method="post">
<input type="hidden" name="op" value="reset_confirmed" />
<button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, reset mappings</button>
</form>
<br>
<form method="post">
<button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not reset mappings</button>
</form>
</div>
[% END %]
<form method="post">
<div id="tabs" class="toptabs" style="clear:both">
<ul>
<li><a href="#search_fields">Search fields</a></li>
[% FOREACH index IN indexes %]
[% SWITCH index.index_name %]
[% CASE 'biblios' %]<li><a href="#mapping_biblios">Bibliographic records</a></li>
[% CASE 'authorities' %]<li><a href="#mapping_authorities">Authorities</a></li>
[% END %]
[% END %]
</ul>
<div id="search_fields">
<table class="search_fields">
<thead>
<tr>
<th>Name</th>
<th>Label</th>
<th>Type</th>
<th>Weight</th>
</tr>
</thead>
<tbody>
[% FOREACH search_field IN all_search_fields %]
<tr>
<td>
<input type="text" name="search_field_name" value="[% search_field.name | html %]" />
</td>
<td><input type="text" name="search_field_label" value="[% search_field.label | html %]" />
<td>
<select name="search_field_type">
<option value=""></option>
[% IF search_field.type == "string" %]
<option value="string" selected="selected">String</option>
[% ELSE %]
<option value="string">String</option>
[% END %]
[% IF search_field.type == "date" %]
<option value="date" selected="selected">Date</option>
[% ELSE %]
<option value="date">Date</option>
[% END %]
[% IF search_field.type == "number" %]
<option value="number" selected="selected">Number</option>
[% ELSE %]
<option value="number">Number</option>
[% END %]
[% IF search_field.type == "boolean" %]
<option value="boolean" selected="selected">Boolean</option>
[% ELSE %]
<option value="boolean">Boolean</option>
[% END %]
[% IF search_field.type == "sum" %]
<option value="sum" selected="selected">Sum</option>
[% ELSE %]
<option value="sum">Sum</option>
[% END %]
[% IF search_field.type == "isbn" %]
<option value="isbn" selected="selected">ISBN</option>
[% ELSE %]
<option value="isbn">ISBN</option>
[% END %]
[% IF search_field.type == "stdno" %]
<option value="stdno" selected="selected">Std. Number</option>
[% ELSE %]
<option value="stdno">Std. Number</option>
[% END %]
</select>
</td>
<td>
[% IF search_field.mapped_biblios %]
<input type="number" step="0.01" min="0.01" max="999.99" name="search_field_weight" value="[% search_field.weight | html %]" />
[% ELSE %]
<input type="hidden" name="search_field_weight" value="">
[% END %]
</td>
</tr>
[% END %]
</tbody>
</table>
</div>
[% FOREACH index IN indexes %]
<div id="mapping_[% index.index_name | html %]">
<table class="mappings" data-index_name="[% index.index_name | html %]">
<thead>
<tr class="nodrag nodrop">
<th>Search field</th>
<th>Sortable</th>
<th>Facetable</th>
<th>Suggestible</th>
<th>Mapping</th>
<th></th>
</tr>
</thead>
<tbody>
[% FOREACH mapping IN index.mappings %]
<tr>
<td>
<input type="hidden" name="mapping_index_name" value="[% index.index_name | html %]" />
<input type="hidden" name="mapping_search_field_name" value="[% mapping.search_field_name | html %]">
[% mapping.search_field_label | html %]
</td>
<td>
<select name="mapping_sort">
[% IF mapping.sort == 'undef' %]
<option value="undef" selected="selected">Undef</option>
[% ELSE %]
<option value="undef">Undef</option>
[% END %]
[% IF mapping.sort == 0 %]
<option value="0" selected="selected">0</option>
[% ELSE %]
<option value="0">0</option>
[% END %]
[% IF mapping.sort == 1 %]
<option value="1" selected="selected">1</option>
[% ELSE %]
<option value="1">1</option>
[% END %]
</select>
</td>
<td>
[% IF mapping.is_facetable %]
<select name="mapping_facet">
[% IF mapping.facet %]
<option value="0">No</option>
<option value="1" selected="selected">Yes</option>
[% ELSE %]
<option value="0" selected="selected">No</option>
<option value="1">Yes</option>
[% END %]
</select>
[% ELSE %]
<input type="hidden" name="mapping_facet" value="0" />
No
[% END %]
</td>
<td>
<select name="mapping_suggestible">
[% IF mapping.suggestible %]
<option value="0">No</option>
<option value="1" selected="selected">Yes</option>
[% ELSE %]
<option value="0" selected="selected">No</option>
<option value="1">Yes</option>
[% END %]
</select>
</td>
<td>
<input name="mapping_marc_field" type="text" value="[% mapping.marc_field | html %]" />
</td>
<td><a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> Delete</a></td>
</tr>
[% END %]
</tbody>
<tfoot>
<tr class="nodrag nodrop">
<td>
<input data-id="mapping_index_name" type="hidden" value="[% index.index_name | html %]" />
<select data-id="mapping_search_field_name">
[% FOREACH f IN all_search_fields %]
<option value="[% f.name | html %]">[% f.name | html %]</option>
[% END %]
</select>
</td>
<td>
<select data-id="mapping_sort">
<option value="undef">Undef</option>
<option value="0">0</option>
<option value="1">1</option>
</select>
</td>
<td>
<select data-id="mapping_facet">
[% IF mapping.facet %]
<option value="0">No</option>
<option value="1" selected="selected">Yes</option>
[% ELSE %]
<option value="0" selected="selected">No</option>
<option value="1">Yes</option>
[% END %]
</select>
</td>
<td>
<select data-id="mapping_suggestible">
[% IF mapping.suggestible %]
<option value="0">No</option>
<option value="1" selected="selected">Yes</option>
[% ELSE %]
<option value="0" selected="selected">No</option>
<option value="1">Yes</option>
[% END %]
</select>
</td>
<td><input data-id="mapping_marc_field" type="text" /></td>
<td><a class="btn btn-default btn-xs add"><i class="fa fa-plus"></i> Add</a></td>
</tr>
</tfoot>
</table>
[% IF index.index_name == 'biblios' %]
<h3>Facet order</h3>
<div id="facet_[% index.index_name | html %]">
<table>
<thead>
<tr>
<th>Search field</th>
<th>Label</th>
<th>Display</th>
</tr>
</thead>
<tbody>
[% FOREACH f IN facetable_fields %]
<tr>
<td>
[% f.name | html %]
</td>
<td>
[% SWITCH f.name %]
[% CASE 'author' %]Authors
[% CASE 'itype' %]Item Types
[% CASE 'location' %]Locations
[% CASE 'su-geo' %]Places
[% CASE 'title-series' %]Series
[% CASE 'subject' %]Topics
[% CASE 'ccode' %]Collections
[% CASE 'holdingbranch' %]Holding libraries
[% CASE 'homebranch' %]Home libraries
[% CASE %][% f | html %]
[% END %]
</td>
<td>
[% IF f.facet_order %]
<input type="checkbox" name="display_facet" value="[% f.name | html %]" checked="checked" />
[% ELSE %]
<input type="checkbox" name="display_facet" value="[% f.name | html %]" />
[% END %]
</td>
</tr>
[% END %]
</tbody>
</table>
</div>
[% END %]
</div>
[% END %]
</div>
<p>
<button class="btn btn-default" type="submit" name="op" value="edit"><i class="fa fa-hdd-o" aria-hidden="true"></i> Save</button>
<button class="btn btn-default" type="submit" name="op" value="reset_confirm"><i class="fa fa-refresh" aria-hidden="true"></i> Reset Mappings</button>
</p>
</form>
</main>
</div> <!-- /.col-sm-10.col-sm-push-2 -->
<div class="col-sm-2 col-sm-pull-10">
<aside>
[% INCLUDE 'admin-menu.inc' %]
</aside>
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
</div> <!-- /.row -->
[% INCLUDE 'intranet-bottom.inc' %]