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

solr_facet_params defaults to sort=index #976

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion lib/blacklight/solr_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def solr_facet_params(facet_field, user_params=params || {}, extra_controller_pa
# override any field-specific default in the solr request handler.
solr_params[:"f.#{facet_field}.facet.limit"] = limit + 1
solr_params[:"f.#{facet_field}.facet.offset"] = ( input.fetch(Blacklight::Solr::FacetPaginator.request_keys[:page] , 1).to_i - 1 ) * ( limit )
solr_params[:"f.#{facet_field}.facet.sort"] = input[ Blacklight::Solr::FacetPaginator.request_keys[:sort] ] if input[ Blacklight::Solr::FacetPaginator.request_keys[:sort] ]
solr_params[:"f.#{facet_field}.facet.sort"] = input[ Blacklight::Solr::FacetPaginator.request_keys[:sort] ] || "index"
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this is the right solution:

  1. do we always want to default to sorting by index? It seems typical, at least in our use, to default to sorting by count. I also think sorting by count is the solr default.

  2. if i read this right, we'll be sending (number of facets) parameters on every search. Wouldn't it be better to inspect the echo'ed params and parse that our appropriately? It looks like we have code to do this (and that defaults to count) here:

@sort = arguments[:sort] || "count"

But you're right, it seems like it isn't working correctly.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure that we have guaranteed access to echo'd parameters -- does it depend on if Solr is set up to echo, or does BL ask for echo'd parameters regardless?

But if you don't like this solution, I won't do more work to try and make the tests pass (I still can't get tests to run locally on my machine despite many frustrating hours spent on it).

But I really do want a bugfix in my app that's demonstrating the bug, along with the BL demo. I don't really have time to work on figuring out or implementing a more complete solution right now. Is there any chance you'd accept this simple solution until someone has the time and inclination to implement a better one?

Copy link
Member Author

Choose a reason for hiding this comment

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

Or does #977 end up taking care of this for the standard case?

solr_params[:rows] = 0

return solr_params
Expand Down
4 changes: 4 additions & 0 deletions spec/lib/blacklight/solr_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,10 @@ def logger
solr_params = subject.solr_facet_params(@facet_field)
expect(solr_params[:"f.#{@facet_field}.facet.limit"]).to eq 21
end
it "defaults sort to index" do
solr_params = subject.solr_facet_params(@facet_field)
expect(solr_params[:"f.#{@facet_field}.facet.sort"]).to eq "index"
end

describe 'if facet_list_limit is defined in controller' do
before do
Expand Down