diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm index 9aa8d0c54f..cecb1cc609 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -779,7 +779,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; diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t index d4e99ede63..9889c343b5 100755 --- a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t +++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t @@ -962,7 +962,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]); @@ -970,7 +970,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]); @@ -978,7 +978,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,