Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that search_state.query_param responds to match? #1887

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/models/search_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class SearchBuilder < Blacklight::SearchBuilder
# more advanced search queries. Setting `mm=1` means only 1 clause needs to match, but the lucene query parser (in
# edismax) will precompose the query strings so everything works out.
def min_match_for_boolean(solr_parameters)
return unless search_state.query_param&.match?(/\s(AND|OR|NOT)\s/)
return unless search_state.query_param.respond_to?(:match?) &&
search_state.query_param&.match?(/\s(AND|OR|NOT)\s/)

solr_parameters[:mm] = '1'
end
Expand Down
8 changes: 8 additions & 0 deletions spec/models/search_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,13 @@
expect(solr_parameters[:mm]).to be_nil
end
end

context "when the query isn't a string" do
let(:query) { { q: { a: 1 } } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this query occur in the real world?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When an item is embedded on a page in spotlight.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a page I can go to in order to see this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can duplicate this locally by adding an item row widget with one or more items added to it to any custom page in DLME, such as the home page, a feature page or about page. This is blocking Jacob from creating a page in DLME.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging this, but we believe this may just be cover for a deeper issue #1889


it 'does not set min match' do
expect(solr_parameters[:mm]).to be_nil
end
end
end
end