Solr Facets Block Visibility

105 views
Skip to first unread message

Mark McFate

unread,
Jul 20, 2015, 3:35:14 PM7/20/15
to isla...@googlegroups.com
Good afternoon all.  I'm trying to identify a path of least resistance (effort) here.  

Basically, I have a nice 'collections view' set of pages working AND some nice Solr search with facets too.  You can look at https://digital.grinnell.edu/islandora/object/islandora:root and subsequent collection pages for an example of the first, and any https://digital.grinnell.edu/islandora/search page (like https:/digital.grinnell.edu/islandora/search/*:*) for an example of the second.  

Notice that in the 'search' driven pages you see a Facets block in the left sidebar.  

What I'd like to have is that Facets block appearing on every page, even the collection views...essentially I want to seed a search and return/display the corresponding Facets block but not always display the search 'results'.  Anybody know off-hand how to achieve that?  

Thanks in advance.

-Mark

Diego Pino

unread,
Jul 21, 2015, 12:10:07 PM7/21/15
to isla...@googlegroups.com
Hi Mark, the facet blocks depends on an existing query and does a context check before appearing. I don't see a very easy path there, maybe someone else has a better solution, but you could manage to build your own block based on how the islandora solr explore block works. If you look at the code, this particular block does initially a get all query (*:*) and then adds custom facets querys (that have no real use for you, because they assume you are going to use a 'fixed' condition you every facet field you wan't to display)…but:
You could make a new block copying the first part of that block, there could be some info hooks somewhere (don't remember, sorry), but just give this a try first:
Then copy the part of the main facet block (or call internally the needed callbacks and theming stuff), where facet fields are read from the configuration. Strip the facet queries if you want, and you should be done.

But maybe, personal opinion here (so you can stop reading if you wan't), having facets everywhere could be missleading. So maybe you could add some type of context filter based on where you are standing(hey, you can show all facets for objects that belong to the same CMODEL! or same collection!, well just an idea), and/or, if not adding conditions, also a different block title (so people knows they are seeing everything that is available and not those that are related to, e.g the current's objects data. Also there could be some performance issues, but i think most of the facets get cached in Solr, so just try.

Best

Diego

Mark McFate

unread,
Jul 21, 2015, 12:40:30 PM7/21/15
to isla...@googlegroups.com
Hi Diego.

I actually got this worked out nicely, I think, a short time ago but had to run off to a meeting.  Last week you may recall that I introduced a new function named dg7_islandora_basic_collection_query_param_alter (islandora_basic_collection provides a hook) to control collection view sorting based on different requirements for various collections.  This morning I added some calls like this...

islandora_solr('RELS_EXT_isMemberOfCollection_uri_mlt:*phpp');

...to that function and the Facets block subsequently appears on my collection view pages as I hoped it would.   In fact, making this call does much more.  For instance it also populates my advanced Solr search block with this query so that patrons can see what was queried in Solr to arrive at the objects and facets shown.

It's working very nicely thus far but I can't easily share the pages just yet since it is implemented only on my dev server.  A month from now, if it is still working properly, I can show it off. 

Diego Pino

unread,
Jul 21, 2015, 12:46:32 PM7/21/15
to isla...@googlegroups.com
Great! You triggered the correct context by making that =)


Cheers
Reply all
Reply to author
Forward
0 new messages