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

(-)a/Koha/SearchEngine/Elasticsearch.pm (+20 lines)
Lines 770-775 sub marc_records_to_documents { Link Here
770
                $record_document->{'marc_format'} = 'base64ISO2709';
770
                $record_document->{'marc_format'} = 'base64ISO2709';
771
            }
771
            }
772
        }
772
        }
773
774
        # Check if there is at least one available item
775
        if ($self->index eq $BIBLIOS_INDEX) {
776
            my $biblio = Koha::Biblios->find($record->field('001')->data);
777
            my $items = $biblio->items;
778
            my $available = 0;
779
            while (my $item = $items->next) {
780
                next if $item->onloan;
781
                next if $item->notforloan;
782
                next if $item->withdrawn;
783
                next if $item->itemlost;
784
                next if $item->damaged;
785
786
                $available = 1;
787
                last;
788
            }
789
790
            $record_document->{available} = $available ? \1 : \0;
791
        }
792
773
        push @record_documents, $record_document;
793
        push @record_documents, $record_document;
774
    }
794
    }
775
    return \@record_documents;
795
    return \@record_documents;
(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-1 / +1 lines)
Lines 1092-1098 sub _fix_limit_special_cases { Link Here
1092
            }
1092
            }
1093
        }
1093
        }
1094
        elsif ( $l =~ /^available$/ ) {
1094
        elsif ( $l =~ /^available$/ ) {
1095
            push @new_lim, 'onloan:false';
1095
            push @new_lim, 'available:true';
1096
        }
1096
        }
1097
        else {
1097
        else {
1098
            my ( $field, $term ) = $l =~ /^\s*([\w,-]*?):(.*)/;
1098
            my ( $field, $term ) = $l =~ /^\s*([\w,-]*?):(.*)/;
(-)a/admin/searchengine/elasticsearch/mappings.yaml (+3 lines)
Lines 2551-2556 biblios: Link Here
2551
        sort: 0
2551
        sort: 0
2552
        suggestible: ''
2552
        suggestible: ''
2553
    type: boolean
2553
    type: boolean
2554
  available:
2555
    label: available
2556
    type: boolean
2554
  other-control-number:
2557
  other-control-number:
2555
    label: other-control-number
2558
    label: other-control-number
2556
    mappings:
2559
    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