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

(-)a/Koha/SearchEngine/Elasticsearch.pm (+20 lines)
Lines 703-708 sub marc_records_to_documents { Link Here
703
                $record_document->{'marc_format'} = 'base64ISO2709';
703
                $record_document->{'marc_format'} = 'base64ISO2709';
704
            }
704
            }
705
        }
705
        }
706
707
        # Check if there is at least one available item
708
        if ($self->index eq $BIBLIOS_INDEX) {
709
            my $biblio = Koha::Biblios->find($record->field('001')->data);
710
            my $items = $biblio->items;
711
            my $available = 0;
712
            while (my $item = $items->next) {
713
                next if $item->onloan;
714
                next if $item->notforloan;
715
                next if $item->withdrawn;
716
                next if $item->itemlost;
717
                next if $item->damaged;
718
719
                $available = 1;
720
                last;
721
            }
722
723
            $record_document->{available} = $available ? \1 : \0;
724
        }
725
706
        push @record_documents, $record_document;
726
        push @record_documents, $record_document;
707
    }
727
    }
708
    return \@record_documents;
728
    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 3086-3091 biblios: Link Here
3086
        sort: 0
3086
        sort: 0
3087
        suggestible: ''
3087
        suggestible: ''
3088
    type: boolean
3088
    type: boolean
3089
  available:
3090
    label: available
3091
    type: boolean
3089
  other-control-number:
3092
  other-control-number:
3090
    label: other-control-number
3093
    label: other-control-number
3091
    mappings:
3094
    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