From bd56d21fce9978c538e8f4a1d58a7bcf8a63110e Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Fri, 12 Apr 2024 13:49:35 -0400 Subject: [PATCH] Fixes more solr uri issues (#2182) Refs https://github.com/samvera/hyku/issues/2177 --- .../solr/indexing_adapter_decorator.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/valkyrie/indexing/solr/indexing_adapter_decorator.rb b/lib/valkyrie/indexing/solr/indexing_adapter_decorator.rb index 387ac760d..a0550f4b8 100644 --- a/lib/valkyrie/indexing/solr/indexing_adapter_decorator.rb +++ b/lib/valkyrie/indexing/solr/indexing_adapter_decorator.rb @@ -1,13 +1,27 @@ # frozen_string_literal: true -# Override Hyrax v5.0 to avoid incorrect default connection +# Override Hyrax v5.0 to avoid incorrect default connection. Because of the way +# Hyku uses SolrEndpoint, the configuration isn't always appropriate. At times, +# it falls back into the Valkyrie IndexingAdapter instead of Hyrax's, and +# loses the connection. # TODO: create and initialize a Hyku version of the indexing adapter module Valkyrie module Indexing module Solr module IndexingAdapterDecorator + ## + # @param connection [RSolr::Client] The RSolr connection to index to. + def initialize(connection: ::SolrEndpoint.new.connection) + @connection = connection + end + def default_connection - ::SolrEndpoint.new.connection + @connection = ::SolrEndpoint.new.connection + end + + def add_documents(*args) + self.connection = default_connection + super(*args) end end end