From 5411e1f75b11a45c1bf20beebee1e3ba930936a1 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 24 Sep 2019 11:36:43 -0400 Subject: [PATCH] Support bib record transcendance Signed-off-by: Bill Erickson --- .../lib/OpenILS/Application/Search/Elastic.pm | 19 +++++++++++++++++++ .../src/perlmods/lib/OpenILS/Elastic/Bib/Search.pm | 6 +++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Elastic.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Elastic.pm index 0df70bac22..75934bf6c8 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Elastic.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Elastic.pm @@ -36,6 +36,7 @@ my $bib_fields; my $hidden_copy_statuses; my $hidden_copy_locations; my $avail_copy_statuses; +my $transcendant_sources; # NOTE calling cstore functions in child_init is dicey because child_init # may be run before cstore is ready for requests. Use a local init() instead. @@ -75,6 +76,10 @@ sub init { $hidden_copy_locations = [map {$_->{id}} @$locs]; + $transcendant_sources = [ + map {$_->id} @{$e->search_config_bib_source({transcendant => 't'})} + ]; + return 1; } @@ -365,6 +370,20 @@ sub add_elastic_holdings_filter { $logger->info("ES holdings filter is " . OpenSRF::Utils::JSON->perl2JSON($filter)); + # If we reach this point, we are performing some level of holdings + # filtering. Transcendant bib records are considered visible and + # available, so allow them to bubble up through the holdings filter. + if (@$transcendant_sources) { + $filter = { + bool => {must => { # 'must' enforce at least one 'should' + bool => {should => [ + {terms => {bib_source => $transcendant_sources}}, + $filter + ]} + }} + }; + } + # array of filters in progress push(@{$elastic_query->{query}->{bool}->{filter}}, $filter); } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Elastic/Bib/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/Elastic/Bib/Search.pm index b4dc6c6a0e..b328be071d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Elastic/Bib/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Elastic/Bib/Search.pm @@ -49,9 +49,9 @@ my $BASE_INDEX_SETTINGS = { # Well-known bib-search index properties my $BASE_PROPERTIES = { - source => {type => 'integer', index => 'false'}, - create_date => {type => 'date', index => 'false'}, - edit_date => {type => 'date', index => 'false'}, + bib_source => {type => 'integer'}, + create_date => {type => 'date'}, + edit_date => {type => 'date'}, # Holdings summaries. For bib-search, we don't need # copy-specific details, only aggregate visibility information. -- 2.11.0