@@ -, +, @@ --- Koha/SearchEngine/Elasticsearch.pm | 2 +- t/db_dependent/Koha/SearchEngine/Elasticsearch.t | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) --- a/Koha/SearchEngine/Elasticsearch.pm +++ a/Koha/SearchEngine/Elasticsearch.pm @@ -781,7 +781,7 @@ sub marc_records_to_documents { my $avail_items = Koha::Items->search({ biblionumber => $biblionumber, onloan => undef, - notforloan => 0, + itemlost => 0, })->count; $record_document->{available} = $avail_items ? \1 : \0; --- a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t +++ a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t @@ -1006,7 +1006,7 @@ subtest 'marc_records_to_documents should set the "available" field' => sub { $item->notforloan(1)->store(); $docs = $see->marc_records_to_documents([$marc_record_1]); - is_deeply($docs->[0]->{available}, \0, 'a biblio with one item that is "notforloan" is not available'); + is_deeply($docs->[0]->{available}, \1, 'a biblio with one item that is "notforloan" is available'); $item->set({ notforloan => 0, onloan => '2022-03-03' })->store(); $docs = $see->marc_records_to_documents([$marc_record_1]); @@ -1014,7 +1014,7 @@ subtest 'marc_records_to_documents should set the "available" field' => sub { $item->set({ onloan => undef, withdrawn => 1 })->store(); $docs = $see->marc_records_to_documents([$marc_record_1]); - is_deeply($docs->[0]->{available}, \0, 'a biblio with one item that is withdrawn is not available'); + is_deeply($docs->[0]->{available}, \1, 'a biblio with one item that is withdrawn is available'); $item->set({ withdrawn => 0, itemlost => 1 })->store(); $docs = $see->marc_records_to_documents([$marc_record_1]); @@ -1022,7 +1022,7 @@ subtest 'marc_records_to_documents should set the "available" field' => sub { $item->set({ itemlost => 0, damaged => 1 })->store(); $docs = $see->marc_records_to_documents([$marc_record_1]); - is_deeply($docs->[0]->{available}, \0, 'a biblio with one item that is damaged is not available'); + is_deeply($docs->[0]->{available}, \1, 'a biblio with one item that is damaged is available'); my $item2 = Koha::Item->new({ biblionumber => $biblionumber, --