Skip to content

Commit efc5865

Browse files
committed
Disable did you mean for elasticsearch
1 parent 0a24f81 commit efc5865

File tree

11 files changed

+31
-10
lines changed

11 files changed

+31
-10
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<%= render 'did_you_mean' %>
2-
<%= render 'sort_and_per_page' %>
1+
<%= render 'did_you_mean' if did_you_mean? %>
2+
<%= render 'sort_and_per_page' %>

app/components/blacklight/search_header_component.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@
22

33
module Blacklight
44
class SearchHeaderComponent < Blacklight::Component
5+
# Should we draw the did_you_mean component?
6+
# Currently not supported with elasticsearch
7+
def did_you_mean?
8+
Blacklight.solr?
9+
end
510
end
611
end

lib/blacklight.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ def self.default_index=(repository)
2424
Blacklight::RuntimeRegistry.connection = repository
2525
end
2626

27+
# @return [Bool] Are we configured to use solr?
28+
def self.solr?
29+
repository_class == Blacklight::Solr::Repository
30+
end
31+
2732
##
2833
# The configured repository class. By convention, this is
2934
# the class Blacklight::(name of the adapter)::Repository, e.g.

lib/blacklight/configuration/facet_field.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ def normalize! blacklight_config = nil
8282
super
8383

8484
if single && tag.blank? && ex.blank?
85-
if Blacklight.repository_class == Blacklight::Elasticsearch::Repository
86-
Blacklight.logger.warn "the `single' property on the facet configuration (for #{key}) is not yet supported for elasticsearch"
87-
else
85+
if Blacklight.solr?
8886
self.tag = "#{key}_single"
8987
self.ex = "#{key}_single"
88+
else
89+
Blacklight.logger.warn "the `single' property on the facet configuration (for #{key}) is not yet supported for elasticsearch"
9090
end
9191
end
9292

lib/blacklight/elasticsearch/response.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def grouped?
6767
end
6868

6969
def spelling
70+
raise "XXXXXX"
7071
nil
7172
end
7273

lib/generators/blacklight/solr_generator.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def install_solrwrapper
3030
end
3131

3232
def copy_solr_conf
33+
raise "XXXXXX"
3334
directory 'solr'
3435
end
3536

spec/controllers/catalog_controller_spec.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,22 @@
2727
it "has docs and facets for query with results", :integration do
2828
get :index, params: { q: user_query }
2929
expect(assigns(:response).docs).not_to be_empty
30+
3031
assert_facets_have_values(assigns(:response).aggregations)
3132
end
3233

3334
it "has docs and facets for existing facet value", :integration do
3435
get :index, params: { f: { "format" => 'Book' } }
3536
expect(assigns(:response).docs).not_to be_empty
37+
3638
assert_facets_have_values(assigns(:response).aggregations)
3739
end
3840

3941
it "has docs and facets for non-default results per page", :integration do
4042
num_per_page = 7
4143
get :index, params: { per_page: num_per_page }
4244
expect(assigns(:response).docs).to have(num_per_page).items
45+
4346
assert_facets_have_values(assigns(:response).aggregations)
4447
end
4548

@@ -48,6 +51,7 @@
4851
get :index, params: { page: page }
4952
expect(assigns(:response).docs).not_to be_empty
5053
expect(assigns(:response).params[:start].to_i).to eq (page - 1) * controller.blacklight_config[:default_solr_params][:rows]
54+
5155
assert_facets_have_values(assigns(:response).aggregations)
5256
end
5357

@@ -74,7 +78,7 @@
7478
expect(assigns(:response).docs).to be_empty
7579
end
7680

77-
it "has a spelling suggestion for an appropriately poor query", :integration do
81+
it "has a spelling suggestion for an appropriately poor query", :integration, :solr do
7882
get :index, params: { q: 'boo' }
7983
expect(assigns(:response).spelling.words).not_to be_nil
8084
end
@@ -102,6 +106,7 @@
102106

103107
it "gets facets when no query", :integration do
104108
get :index
109+
105110
assert_facets_have_values(assigns(:response).aggregations)
106111
end
107112
end
@@ -246,6 +251,7 @@
246251

247252
it "redirects to show action for doc id" do
248253
put :track, params: { id: doc_id, counter: 3 }
254+
249255
assert_redirected_to(solr_document_path(doc_id))
250256
end
251257

@@ -256,16 +262,19 @@
256262

257263
it "redirects to the path given in the redirect param" do
258264
put :track, params: { id: doc_id, counter: 3, redirect: '/xyz' }
265+
259266
assert_redirected_to("/xyz")
260267
end
261268

262269
it "redirects to the path of the uri given in the redirect param" do
263270
put :track, params: { id: doc_id, counter: 3, redirect: 'http://localhost:3000/xyz' }
271+
264272
assert_redirected_to("/xyz")
265273
end
266274

267275
it "keeps querystring on redirect" do
268276
put :track, params: { id: doc_id, counter: 3, redirect: 'http://localhost:3000/xyz?locale=pt-BR' }
277+
269278
assert_redirected_to("/xyz?locale=pt-BR")
270279
end
271280
end

spec/features/did_you_mean_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
RSpec.describe "Did You Mean" do
3+
RSpec.describe "Did You Mean", :solr do
44
before { visit root_path }
55

66
describe "searching all fields" do

spec/integration/generators/blacklight/solr_generator_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require 'spec_helper'
44
require 'generators/blacklight/solr_generator'
55

6-
RSpec.describe Blacklight::SolrGenerator do
6+
RSpec.describe Blacklight::SolrGenerator, :solr do
77
let(:destination) { Dir.mktmpdir }
88

99
describe "#solr_wrapper_config" do

spec/services/blacklight/search_service_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@
309309
end
310310

311311
# SPECS FOR SPELLING SUGGESTIONS VIA SEARCH
312-
describe "Searches should return spelling suggestions", :integration do
312+
describe "Searches should return spelling suggestions", :integration, :solr do
313313
context "for just-poor-enough-query term" do
314314
let(:user_params) { { q: 'boo' } }
315315

0 commit comments

Comments
 (0)