View | Details | Raw Unified | Return to bug 25375
Collapse All | Expand All

(-)a/Koha/SearchEngine/Elasticsearch.pm (+20 lines)
Lines 707-712 sub marc_records_to_documents { Link Here
707
                $record_document->{'marc_format'} = 'base64ISO2709';
707
                $record_document->{'marc_format'} = 'base64ISO2709';
708
            }
708
            }
709
        }
709
        }
710
711
        # Check if there is at least one available item
712
        if ($self->index eq $BIBLIOS_INDEX) {
713
            my $biblio = Koha::Biblios->find($record->field('001')->data);
714
            my $items = $biblio->items;
715
            my $available = 0;
716
            while (my $item = $items->next) {
717
                next if $item->onloan;
718
                next if $item->notforloan;
719
                next if $item->withdrawn;
720
                next if $item->itemlost;
721
                next if $item->damaged;
722
723
                $available = 1;
724
                last;
725
            }
726
727
            $record_document->{available} = $available ? \1 : \0;
728
        }
729
710
        push @record_documents, $record_document;
730
        push @record_documents, $record_document;
711
    }
731
    }
712
    return \@record_documents;
732
    return \@record_documents;
(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-1 / +1 lines)
Lines 1010-1016 sub _fix_limit_special_cases { Link Here
1010
            push @new_lim, "copydate:$date";
1010
            push @new_lim, "copydate:$date";
1011
        }
1011
        }
1012
        elsif ( $l =~ /^available$/ ) {
1012
        elsif ( $l =~ /^available$/ ) {
1013
            push @new_lim, 'onloan:false';
1013
            push @new_lim, 'available:true';
1014
        }
1014
        }
1015
        else {
1015
        else {
1016
            my ( $field, $term ) = $l =~ /^\s*([\w,-]*?):(.*)/;
1016
            my ( $field, $term ) = $l =~ /^\s*([\w,-]*?):(.*)/;
(-)a/admin/searchengine/elasticsearch/mappings.yaml (+3 lines)
Lines 3110-3115 biblios: Link Here
3110
        sort: 0
3110
        sort: 0
3111
        suggestible: ''
3111
        suggestible: ''
3112
    type: boolean
3112
    type: boolean
3113
  available:
3114
    label: available
3115
    type: boolean
3113
  other-control-number:
3116
  other-control-number:
3114
    label: other-control-number
3117
    label: other-control-number
3115
    mappings:
3118
    mappings:
(-)a/installer/data/mysql/atomicupdate/bug-25375.perl (-1 / +9 lines)
Line 0 Link Here
0
- 
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do(qq{
4
        INSERT IGNORE INTO search_field (name, label, type)
5
        VALUES ('available', 'available', 'boolean')
6
    });
7
8
    NewVersion( $DBversion, '25735', "Add Elasticsearch field 'available'");
9
}

Return to bug 25375