Bug 25375: Fix 'available' facet in elasticsearch
Add a new boolean ES field named 'available', which is true if at least one item is available, which means the item is not on loan, not "notforloan", not withdrawn, not lost and not damaged A full indexation is required Test plan: 1. Apply patch and run updatedatabase.pl 2. Run `misc/search_tools/rebuild_elasticsearch.pl -d -b` 3. Make sure you have some biblios whose items are all unavailable, some biblios whose items are all available, and some biblios with at least one item available and at least one item unavailable 4. Use the 'available' filter on both opac and intranet and make sure it works as expected. Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
6523db7321
commit
d79361c51e
|
|
@ -770,6 +770,26 @@ sub marc_records_to_documents {
|
|||
$record_document->{'marc_format'} = 'base64ISO2709';
|
||||
}
|
||||
}
|
||||
|
||||
# Check if there is at least one available item
|
||||
if ($self->index eq $BIBLIOS_INDEX) {
|
||||
my $biblio = Koha::Biblios->find($record->field('001')->data);
|
||||
my $items = $biblio->items;
|
||||
my $available = 0;
|
||||
while (my $item = $items->next) {
|
||||
next if $item->onloan;
|
||||
next if $item->notforloan;
|
||||
next if $item->withdrawn;
|
||||
next if $item->itemlost;
|
||||
next if $item->damaged;
|
||||
|
||||
$available = 1;
|
||||
last;
|
||||
}
|
||||
|
||||
$record_document->{available} = $available ? \1 : \0;
|
||||
}
|
||||
|
||||
push @record_documents, $record_document;
|
||||
}
|
||||
return \@record_documents;
|
||||
|
|
|
|||
|
|
@ -1102,7 +1102,7 @@ sub _fix_limit_special_cases {
|
|||
}
|
||||
}
|
||||
elsif ( $l =~ /^available$/ ) {
|
||||
push @new_lim, 'onloan:false';
|
||||
push @new_lim, 'available:true';
|
||||
}
|
||||
else {
|
||||
my ( $field, $term ) = $l =~ /^\s*([\w,-]*?):(.*)/;
|
||||
|
|
|
|||
|
|
@ -2551,6 +2551,9 @@ biblios:
|
|||
sort: 0
|
||||
suggestible: ''
|
||||
type: boolean
|
||||
available:
|
||||
label: available
|
||||
type: boolean
|
||||
other-control-number:
|
||||
label: other-control-number
|
||||
mappings:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
$DBversion = 'XXX';
|
||||
if( CheckVersion( $DBversion ) ) {
|
||||
$dbh->do(qq{
|
||||
INSERT IGNORE INTO search_field (name, label, type)
|
||||
VALUES ('available', 'available', 'boolean')
|
||||
});
|
||||
|
||||
NewVersion( $DBversion, '25735', "Add Elasticsearch field 'available'");
|
||||
}
|
||||
Loading…
Reference in New Issue