Bug 25054: Display search field aliases in Search Engine Configuration
It'd be great if the Search Engine Configuration page would display the various aliases (shortcuts) available : ti for title, sn for local-number, etc. Patch changes Koha/SearchEngine/Elasticsearch/QueryBuilder.pm to move hard-coded vars at the beging and adds a method to provide to %index_field_convert via a method. Test plan : 1) Use Elasticsearch 2) Go to Administration > Search engine configuration (Elasticsearch) 3) Check you see new column 'Aliases' with for example ti for title. 4) Perform a search 'ti:<title>' and check you get results Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
3a1dea7612
commit
fd8aee9270
|
|
@ -50,6 +50,111 @@ use C4::Context;
|
|||
use Koha::Exceptions;
|
||||
use Koha::Caches;
|
||||
|
||||
our %index_field_convert = (
|
||||
'kw' => '',
|
||||
'ab' => 'abstract',
|
||||
'au' => 'author',
|
||||
'lcn' => 'local-classification',
|
||||
'callnum' => 'local-classification',
|
||||
'record-type' => 'rtype',
|
||||
'mc-rtype' => 'rtype',
|
||||
'mus' => 'rtype',
|
||||
'lc-card' => 'lc-card-number',
|
||||
'sn' => 'local-number',
|
||||
'biblionumber' => 'local-number',
|
||||
'yr' => 'date-of-publication',
|
||||
'pubdate' => 'date-of-publication',
|
||||
'acqdate' => 'date-of-acquisition',
|
||||
'date/time-last-modified' => 'date-time-last-modified',
|
||||
'dtlm' => 'date-time-last-modified',
|
||||
'diss' => 'dissertation-information',
|
||||
'nb' => 'isbn',
|
||||
'ns' => 'issn',
|
||||
'music-number' => 'identifier-publisher-for-music',
|
||||
'number-music-publisher' => 'identifier-publisher-for-music',
|
||||
'music' => 'identifier-publisher-for-music',
|
||||
'ident' => 'identifier-standard',
|
||||
'cpn' => 'corporate-name',
|
||||
'cfn' => 'conference-name',
|
||||
'pn' => 'personal-name',
|
||||
'pb' => 'publisher',
|
||||
'pv' => 'provider',
|
||||
'nt' => 'note',
|
||||
'notes' => 'note',
|
||||
'rcn' => 'record-control-number',
|
||||
'su' => 'subject',
|
||||
'su-to' => 'subject',
|
||||
#'su-geo' => 'subject',
|
||||
'su-ut' => 'subject',
|
||||
'ti' => 'title',
|
||||
'se' => 'title-series',
|
||||
'ut' => 'title-uniform',
|
||||
'an' => 'koha-auth-number',
|
||||
'authority-number' => 'koha-auth-number',
|
||||
'at' => 'authtype',
|
||||
'he' => 'heading',
|
||||
'rank' => 'relevance',
|
||||
'phr' => 'st-phrase',
|
||||
'wrdl' => 'st-word-list',
|
||||
'rt' => 'right-truncation',
|
||||
'rtrn' => 'right-truncation',
|
||||
'ltrn' => 'left-truncation',
|
||||
'rltrn' => 'left-and-right',
|
||||
'mc-itemtype' => 'itemtype',
|
||||
'mc-ccode' => 'ccode',
|
||||
'branch' => 'homebranch',
|
||||
'mc-loc' => 'location',
|
||||
'loc' => 'location',
|
||||
'stocknumber' => 'number-local-acquisition',
|
||||
'inv' => 'number-local-acquisition',
|
||||
'bc' => 'barcode',
|
||||
'mc-itype' => 'itype',
|
||||
'aub' => 'author-personal-bibliography',
|
||||
'auo' => 'author-in-order',
|
||||
'ff8-22' => 'ta',
|
||||
'aud' => 'ta',
|
||||
'audience' => 'ta',
|
||||
'frequency-code' => 'ff8-18',
|
||||
'illustration-code' => 'ff8-18-21',
|
||||
'regularity-code' => 'ff8-19',
|
||||
'type-of-serial' => 'ff8-21',
|
||||
'format' => 'ff8-23',
|
||||
'conference-code' => 'ff8-29',
|
||||
'festschrift-indicator' => 'ff8-30',
|
||||
'index-indicator' => 'ff8-31',
|
||||
'fiction' => 'lf',
|
||||
'fic' => 'lf',
|
||||
'literature-code' => 'lf',
|
||||
'biography' => 'bio',
|
||||
'ff8-34' => 'bio',
|
||||
'biography-code' => 'bio',
|
||||
'l-format' => 'ff7-01-02',
|
||||
'lex' => 'lexile-number',
|
||||
'hi' => 'host-item-number',
|
||||
'itu' => 'index-term-uncontrolled',
|
||||
'itg' => 'index-term-genre',
|
||||
);
|
||||
my $field_name_pattern = '[\w\-]+';
|
||||
my $multi_field_pattern = "(?:\\.$field_name_pattern)*";
|
||||
|
||||
=head2 get_index_field_convert
|
||||
|
||||
my @index_params = Koha::SearchEngine::Elasticsearch::QueryBuilder->get_index_field_convert();
|
||||
|
||||
Converts zebra-style search index notation into elasticsearch-style.
|
||||
|
||||
C<@indexes> is an array of index names, as presented to L<build_query_compat>,
|
||||
and it returns something that can be sent to L<build_query>.
|
||||
|
||||
B<TODO>: this will pull from the elasticsearch mappings table to figure out
|
||||
types.
|
||||
|
||||
=cut
|
||||
|
||||
sub get_index_field_convert() {
|
||||
return \%index_field_convert;
|
||||
}
|
||||
|
||||
=head2 build_query
|
||||
|
||||
my $simple_query = $builder->build_query("hello", %options)
|
||||
|
|
@ -608,107 +713,6 @@ sub _convert_sort_fields {
|
|||
} @sort_by;
|
||||
}
|
||||
|
||||
=head2 _convert_index_fields
|
||||
|
||||
my @index_params = $self->_convert_index_fields(@indexes);
|
||||
|
||||
Converts zebra-style search index notation into elasticsearch-style.
|
||||
|
||||
C<@indexes> is an array of index names, as presented to L<build_query_compat>,
|
||||
and it returns something that can be sent to L<build_query>.
|
||||
|
||||
B<TODO>: this will pull from the elasticsearch mappings table to figure out
|
||||
types.
|
||||
|
||||
=cut
|
||||
|
||||
our %index_field_convert = (
|
||||
'kw' => '',
|
||||
'ab' => 'abstract',
|
||||
'au' => 'author',
|
||||
'lcn' => 'local-classification',
|
||||
'callnum' => 'local-classification',
|
||||
'record-type' => 'rtype',
|
||||
'mc-rtype' => 'rtype',
|
||||
'mus' => 'rtype',
|
||||
'lc-card' => 'lc-card-number',
|
||||
'sn' => 'local-number',
|
||||
'biblionumber' => 'local-number',
|
||||
'yr' => 'date-of-publication',
|
||||
'pubdate' => 'date-of-publication',
|
||||
'acqdate' => 'date-of-acquisition',
|
||||
'date/time-last-modified' => 'date-time-last-modified',
|
||||
'dtlm' => 'date-time-last-modified',
|
||||
'diss' => 'dissertation-information',
|
||||
'nb' => 'isbn',
|
||||
'ns' => 'issn',
|
||||
'music-number' => 'identifier-publisher-for-music',
|
||||
'number-music-publisher' => 'identifier-publisher-for-music',
|
||||
'music' => 'identifier-publisher-for-music',
|
||||
'ident' => 'identifier-standard',
|
||||
'cpn' => 'corporate-name',
|
||||
'cfn' => 'conference-name',
|
||||
'pn' => 'personal-name',
|
||||
'pb' => 'publisher',
|
||||
'pv' => 'provider',
|
||||
'nt' => 'note',
|
||||
'notes' => 'note',
|
||||
'rcn' => 'record-control-number',
|
||||
'su' => 'subject',
|
||||
'su-to' => 'subject',
|
||||
#'su-geo' => 'subject',
|
||||
'su-ut' => 'subject',
|
||||
'ti' => 'title',
|
||||
'se' => 'title-series',
|
||||
'ut' => 'title-uniform',
|
||||
'an' => 'koha-auth-number',
|
||||
'authority-number' => 'koha-auth-number',
|
||||
'at' => 'authtype',
|
||||
'he' => 'heading',
|
||||
'rank' => 'relevance',
|
||||
'phr' => 'st-phrase',
|
||||
'wrdl' => 'st-word-list',
|
||||
'rt' => 'right-truncation',
|
||||
'rtrn' => 'right-truncation',
|
||||
'ltrn' => 'left-truncation',
|
||||
'rltrn' => 'left-and-right',
|
||||
'mc-itemtype' => 'itemtype',
|
||||
'mc-ccode' => 'ccode',
|
||||
'branch' => 'homebranch',
|
||||
'mc-loc' => 'location',
|
||||
'loc' => 'location',
|
||||
'stocknumber' => 'number-local-acquisition',
|
||||
'inv' => 'number-local-acquisition',
|
||||
'bc' => 'barcode',
|
||||
'mc-itype' => 'itype',
|
||||
'aub' => 'author-personal-bibliography',
|
||||
'auo' => 'author-in-order',
|
||||
'ff8-22' => 'ta',
|
||||
'aud' => 'ta',
|
||||
'audience' => 'ta',
|
||||
'frequency-code' => 'ff8-18',
|
||||
'illustration-code' => 'ff8-18-21',
|
||||
'regularity-code' => 'ff8-19',
|
||||
'type-of-serial' => 'ff8-21',
|
||||
'format' => 'ff8-23',
|
||||
'conference-code' => 'ff8-29',
|
||||
'festschrift-indicator' => 'ff8-30',
|
||||
'index-indicator' => 'ff8-31',
|
||||
'fiction' => 'lf',
|
||||
'fic' => 'lf',
|
||||
'literature-code' => 'lf',
|
||||
'biography' => 'bio',
|
||||
'ff8-34' => 'bio',
|
||||
'biography-code' => 'bio',
|
||||
'l-format' => 'ff7-01-02',
|
||||
'lex' => 'lexile-number',
|
||||
'hi' => 'host-item-number',
|
||||
'itu' => 'index-term-uncontrolled',
|
||||
'itg' => 'index-term-genre',
|
||||
);
|
||||
my $field_name_pattern = '[\w\-]+';
|
||||
my $multi_field_pattern = "(?:\\.$field_name_pattern)*";
|
||||
|
||||
sub _convert_index_fields {
|
||||
my ( $self, @indexes ) = @_;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ use C4::Auth;
|
|||
use C4::Log;
|
||||
|
||||
use Koha::SearchEngine::Elasticsearch;
|
||||
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
|
||||
use Koha::SearchMarcMaps;
|
||||
use Koha::SearchFields;
|
||||
use Koha::Caches;
|
||||
|
|
@ -78,6 +79,14 @@ my $update_mappings = sub {
|
|||
}
|
||||
};
|
||||
|
||||
my $search_fields_aliases = {};
|
||||
while ( my ( $key, $value ) = each(%{Koha::SearchEngine::Elasticsearch::QueryBuilder->get_index_field_convert}) ) {
|
||||
my $field_aliases = $search_fields_aliases->{$value};
|
||||
$field_aliases = [] unless $field_aliases;
|
||||
push @$field_aliases, $key;
|
||||
$search_fields_aliases->{$value} = $field_aliases;
|
||||
}
|
||||
|
||||
if ( $op eq 'edit' ) {
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
|
@ -265,6 +274,7 @@ my @all_search_fields;
|
|||
while ( my $search_field = $search_fields->next ) {
|
||||
my $search_field_unblessed = $search_field->unblessed;
|
||||
$search_field_unblessed->{mapped_biblios} = 1 if $search_field->is_mapped_biblios;
|
||||
$search_field_unblessed->{aliases} = $search_fields_aliases->{$search_field_unblessed->{name}};
|
||||
push @all_search_fields, $search_field_unblessed;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -169,13 +169,14 @@ a.add, a.delete {
|
|||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Aliases</th>
|
||||
<th>Label</th>
|
||||
<th>Type</th>
|
||||
<th colspan="2">Searchable</th>
|
||||
<th>Weight</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan=3> </th>
|
||||
<th colspan=4> </th>
|
||||
<th>Staff interface</th>
|
||||
<th>OPAC</th>
|
||||
<th> </th>
|
||||
|
|
@ -191,6 +192,9 @@ a.add, a.delete {
|
|||
<input type="text" name="search_field_name" value="[% search_field.name | html %]" />
|
||||
[% END %]
|
||||
</td>
|
||||
<td>
|
||||
[% search_field.aliases.join(',') | html %]
|
||||
</td>
|
||||
<td>
|
||||
[% IF search_field.mandatory %]
|
||||
<input type="text" name="search_field_label" value="[% search_field.label | html %]" readonly />
|
||||
|
|
|
|||
Loading…
Reference in New Issue