Support bib record transcendance
authorBill Erickson <berickxx@gmail.com>
Tue, 24 Sep 2019 15:36:43 +0000 (11:36 -0400)
committerBill Erickson <berickxx@gmail.com>
Tue, 15 Oct 2019 18:09:56 +0000 (14:09 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Elastic.pm
Open-ILS/src/perlmods/lib/OpenILS/Elastic/Bib/Search.pm

index 0df70ba..75934bf 100644 (file)
@@ -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);
 }
index b4dc6c6..b328be0 100644 (file)
@@ -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.