SOLR facet alter

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
Anonymous's picture

I have a site that is using SOLR search with just a couple facets. The filter by type facet works for my needs out of the box without much adjustment. However, I need to change the markup of the 'sort by' facet to be a 'select' list rather than a unordered list to match the design.

I have been searching for a solution to this, but have yet to find one. The site is in D7 w apachesolr 7.x-1.0-beta16.

Any help would be greatly appreciated.

-Jeff

Comments

What type of facets do you

Bob Newby's picture

What type of facets do you have? Are they defined as terms of one or more Taxonomy vocabularies? Can you provide a partial example?

thanks for the response Bob.

jshamley's picture

thanks for the response Bob. I have a filter by content type facet and the standard sort by facet. The sort by facet is the one that I need to alter.

The sort by facet is the block to sort by relevancy, title, type, author or date.

On this site, you can see the facet that I'm speaking of just above the search box. http://www.powderbulksolids.com/search/site/powder

Thanks!
-Jeff

Jeff, You may want to consult

Bob Newby's picture

Jeff,

You may want to consult Facet API (http://drupal.org/project/facetapi) and its documentation (http://www.trellon.com/content/blog/apachesolr-and-facetapi).

On the other hand, if it were me in charge of the UX -- and if the facets will remain Relevance, Title, Type, Author, Date -- I would keep their presentation just as it is.

Bob

Facet API doesn't handle sorting

cpliakas's picture

Facet API doesn't create or manage the sorting block, so its documentation won't be any help here. Sorts are not really facets, so generally that functionality is handled by the underlying search module, i.e. Apache Solr Search Integration or Search API.

thanks for the help Bob...I

jshamley's picture

thanks for the help Bob...I too wish the presentation could stay the same. sigh, oh well.

much appreciated.

Unfortunately this isn't as

cpliakas's picture

Unfortunately this isn't as simple as tweaking the sort block to display as a select list as opposed to links :-(. Because the links add the sort information to the query string, the solution is that you will have to create a block in a custom module, copy some of the logic to get the sorting information, build a form via Drupal's FAPI, and then implement a submit handler that redirects to a URL structured in the same way as as the links. I have some code that I will post to a sandbox in a few minutes.

Code has been posted to the

cpliakas's picture

Code has been posted to the Apache Solr Select Sort sandbox. The display probably needs to be tweaked, but it is a starting point. I don't plan on maintaining this module, so if you want to make modifications and maintain it I am perfectly willing to go down that road.

thanks much for the help

jshamley's picture

thanks much for the help guys...I will take a look at the code.

Functionality merged into Apachesolr Sort

cpliakas's picture

The sandbox project I posted implementing this functionality has been merged into Apachesolr Sort.

Lucene, Nutch and Solr

Group organizers

Group categories

Projects

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week