Skip to content

Commit

Permalink
get callnumbers to work with solrcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Dec 14, 2023
1 parent b6c659e commit 54d2345
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ BIBLIO_SOLR='http://biblio-server/solr'
SOLRCLOUD_URL='http://solr-cloud-server/solr'
BROWSE_SOLR='http://catalog-solr-server/solr'
CALLNUMBER_CORE='callnumbers'
CALLNUMBER_COLLECTION='callnumbers'
AUTHORITY_CORE='authority_core'
AUTHORITY_COLLECTION='authority_collection'
SOLR_USER='solr'
SOLR_PASSWORD='SolrRocks'
SOLRCLOUD_ON='false'
SOLRCLOUD_ON='true'
2 changes: 1 addition & 1 deletion lib/utilities/browse_solr_client.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "faraday"

class BrowseSolrClient
def initialize(solr_url: ENV.fetch("BROWSE_SOLR"), core: ENV.fetch("CALLNUMBER_CORE"), match_field: "callnumber", q: "*:*", solrcloud_on: false)
def initialize(solr_url: ENV.fetch("SOLRCLOUD_URL"), core: ENV.fetch("CALLNUMBER_COLLECTION"), match_field: "callnumber", q: "*:*", solrcloud_on: true)
@conn = Faraday.new(
url: solr_url
) do |f|
Expand Down
4 changes: 2 additions & 2 deletions spec/requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
describe "requests" do
include Rack::Test::Methods
before(:each) do
@callnumbers_core = ENV.fetch("CALLNUMBER_CORE")
@authors_core = ENV.fetch("AUTHORITY_CORE")
@callnumbers_core = ENV.fetch("CALLNUMBER_COLLECTION")
@authors_core = ENV.fetch("AUTHORITY_COLLECTION")
end
context "get /" do
it "has status OK" do
Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ def stub_solr_get_request(url:, output: "{}", status: 200, query: nil, no_return
:accept => "*/*",
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
}
req_attributes[:basic_auth] = [S.solr_user, S.solr_password]
req_attributes[:query] = query unless query.nil?
resp = {headers: {content_type: "application/json"}, status: status, body: output}
req = stub_request(:get, "#{ENV["BROWSE_SOLR"]}/#{url}").with(**req_attributes)
req = stub_request(:get, "#{S.solrcloud_url}/#{url}").with(**req_attributes)

if no_return.nil?
req.to_return(**resp)
Expand Down
4 changes: 2 additions & 2 deletions spec/utilities/browse_solr_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
end
context "#exact_matches" do
it "returns an array of ids for an exact match" do
stub_solr_get_request(url: "#{ENV.fetch("CALLNUMBER_CORE")}/select", query: hash_including({fq: 'callnumber:"Thing"'}), output: fixture("biblio_results.json"))
stub_solr_get_request(url: "#{ENV.fetch("CALLNUMBER_COLLECTION")}/select", query: hash_including({fq: 'callnumber:"Thing"'}), output: fixture("biblio_results.json"))
expect(subject.exact_matches(value: "Thing")).to eq(["990059013360106381", "990011613060106381", "990085202960106381", "990155473530106381", "990017586110106381"])
end
it "returns an empty errary if the solr request fails" do
stub_solr_get_request(url: "#{ENV.fetch("CALLNUMBER_CORE")}/select", query: hash_including({fq: 'callnumber:"Thing"'}), no_return: true).to_timeout
stub_solr_get_request(url: "#{ENV.fetch("CALLNUMBER_COLLECTION")}/select", query: hash_including({fq: 'callnumber:"Thing"'}), no_return: true).to_timeout
expect(subject.exact_matches(value: "Thing")).to eq([])
end
end
Expand Down

0 comments on commit 54d2345

Please sign in to comment.