Blacklight Plugin

New search_field request parameter not preserved on sort change

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.4
  • Fix Version/s: 2.5
  • Component/s: None
  • Description:
    Hide
    The new search fields Solr parameterization adds a :search_fields request parameter.

    But changing sort order in the results view loses this search_fields, so you end up seeing different results for the default search when you change sort order.

    Need to investigate, but it sounds like the sort order change is only keeping _particular_ parameters on switch. I suggest it should be changed to _exclude_ particular parameters (mainly :page), and keep everything else -- this will be less fragile, and better accomodate additional request parameters added by extensions like advanced search.
    Show
    The new search fields Solr parameterization adds a :search_fields request parameter. But changing sort order in the results view loses this search_fields, so you end up seeing different results for the default search when you change sort order. Need to investigate, but it sounds like the sort order change is only keeping _particular_ parameters on switch. I suggest it should be changed to _exclude_ particular parameters (mainly :page), and keep everything else -- this will be less fragile, and better accomodate additional request parameters added by extensions like advanced search.

Activity

Hide
Jonathan Rochkind added a comment - 15/Apr/10 12:36 PM
Boy, the weird f[] stuff in the request parameters makes it hard to do this cleanly and DRY.
Show
Jonathan Rochkind added a comment - 15/Apr/10 12:36 PM Boy, the weird f[] stuff in the request parameters makes it hard to do this cleanly and DRY.
Hide
Jonathan Rochkind added a comment - 15/Apr/10 4:27 PM
Fixed and committed.

There is a helper method search_as_hidden_fields which will take the current request params and turn them into hidden form fields, with hash's and arrays done in Rails style. This uses the new HashAsHiddenFields helper that I found on google. This method takes an optional argument of certain keys to admit (:sort, :per_page, :page, etc).

search_form and sort_and_per_page both use this method now, nice and DRY. This method includes ALL existing params _except_ certain specified ones to omit -- so it's nice and future-proofed for future extensions that add more request keys that need to be preserved (like advanced search field).

The former _hidden_filters partial is removed, it is now handled fine by the more general #search_as_hidden_fields

specs for all new methods, feature testing that this issue is indeed resolved.
Show
Jonathan Rochkind added a comment - 15/Apr/10 4:27 PM Fixed and committed. There is a helper method search_as_hidden_fields which will take the current request params and turn them into hidden form fields, with hash's and arrays done in Rails style. This uses the new HashAsHiddenFields helper that I found on google. This method takes an optional argument of certain keys to admit (:sort, :per_page, :page, etc). search_form and sort_and_per_page both use this method now, nice and DRY. This method includes ALL existing params _except_ certain specified ones to omit -- so it's nice and future-proofed for future extensions that add more request keys that need to be preserved (like advanced search field). The former _hidden_filters partial is removed, it is now handled fine by the more general #search_as_hidden_fields specs for all new methods, feature testing that this issue is indeed resolved.

People

Dates

  • Created:
    15/Apr/10 11:25 AM
    Updated:
    15/Apr/10 4:27 PM
    Resolved:
    15/Apr/10 4:27 PM