Skip to content

Commit

Permalink
Merge pull request #3065 from projectblacklight/json-dsl-spellcheck
Browse files Browse the repository at this point in the history
Pass spellcheck.q to solr for JSON DSL queries too
  • Loading branch information
marlo-longley authored May 30, 2024
2 parents 3fd6c15 + d362320 commit e38e0b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/blacklight/solr/search_builder_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def add_search_field_with_json_query_parameters(solr_parameters)
return unless search_state.query_param

bool_query = search_field.clause_params.transform_values { |v| v.merge(query: search_state.query_param) }
solr_parameters["spellcheck.q"] ||= search_state.query_param

solr_parameters.append_boolean_query(:must, bool_query)
end

Expand Down
13 changes: 13 additions & 0 deletions spec/models/blacklight/solr/search_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@
qf: '$subject_qf',
pf: '$subject_pf'
}
blacklight_config.search_fields['subject'].clause_params = nil
end

it "looks up qt from field definition" do
Expand Down Expand Up @@ -374,6 +375,18 @@
expect(key_value_pairs).to include("pf=$subject_pf")
expect(key_value_pairs).to include("qf=$subject_qf")
end

context 'when subject field uses JSON query DSL' do
before do
blacklight_config.search_fields['subject'].clause_params = {
edismax: {}
}
end

it "includes spellcheck.q, without LocalParams" do
expect(subject["spellcheck.q"]).to eq "wome"
end
end
end

describe "solr json query parameters from the fielded search" do
Expand Down

0 comments on commit e38e0b4

Please sign in to comment.