package Koha::ElasticSearch;
-# Copyright 2013 Catalyst IT
+# Copyright 2015 Catalyst IT
#
# This file is part of Koha.
#
my $marcflavour = lc C4::Context->preference('marcflavour');
$self->_foreach_mapping(
sub {
- my ( $name, $type, $facet, $marc_type ) = @_;
+ my ( $name, $type, $facet, $suggestible, $marc_type ) = @_;
return if $marc_type ne $marcflavour;
# TODO if this gets any sort of complexity to it, it should
# be broken out into its own function.
type => "string",
copy_to => "_all.phrase",
},
+ raw => {
+ "type" => "string",
+ "index" => "not_analyzed",
+ }
},
};
$mappings->{data}{properties}{$name}{null_value} = 0
index => "not_analyzed",
};
}
+ if ($suggestible) {
+ $mappings->{data}{properties}{ $name . '__suggestion' } = {
+ type => 'completion',
+ index_analyzer => 'simple',
+ search_analyzer => 'simple',
+ };
+ }
}
);
return $mappings;
my @rules;
$self->_foreach_mapping(
sub {
- my ( $name, $type, $facet, $marc_type, $marc_field ) = @_;
+ my ( $name, $type, $facet, $suggestible, $marc_type, $marc_field ) = @_;
return if $marc_type ne $marcflavour;
my $options = '';
if ($facet) {
push @rules, "marc_map('$marc_field','${name}__facet', $options)";
}
+ if ($suggestible) {
+ push @rules,
+"marc_map('$marc_field','${name}__suggestion.input.\$append', $options)";
+ }
if ( $type eq 'boolean' ) {
# boolean gets special handling, basically if it doesn't exist,
$self->_foreach_mapping(
sub {
- my ( $name, $type, $facet, $marc_type, $marc_field ) = @_;
+ my ( $name, $type, $facet, $suggestible, $marc_type, $marc_field ) = @_;
return unless $marc_type eq 'marc21';
print "Data comes from: " . $marc_field . "\n";
}
my $marc_type = $row->marc_type;
my $marc_field = $row->marc_field;
my $facet = $row->facet;
+ my $suggestible = $row->suggestible;
my $search_field = $row->search_fields();
for my $sf ( $search_field->all ) {
$sub->(
$sf->name,
$sf->type,
$facet,
+ $suggestible,
$marc_type,
$marc_field,
);