csevb10, hunmonk and myself are trying to come to grips with all the various solr-related code that was thrown at the redesign in the various "try to get this page working" attempts throughout the last year or so. One of the things we uncovered was the drupalorg_order_facet module, originally by DamZ from #679180: Implement "order facets". This module isn't at all specific to drupal.org, nor is it specific to order. It is related to solr facets, though, 1 out of 3 words in the title is right. ;)
All it does is it loops through all the enabled solr facets on your site and exposes what I'm calling "result blocks" for each one. A block with a list of the top N results from that particular facet. These result blocks are used heavily in the drupal.org redesign, e.g.:
https://infrastructure.drupal.org/drupal.org-style-guide/prototype/downl...
https://infrastructure.drupal.org/drupal.org-style-guide/prototype/modul...
...
After a brief chat with pwolanin and csevb10 in IRC, we decided we could add this functionality directly to apachesolr as a small add-on module that will live in apachesolr/contrib/apachesolr_result_block
Just opening an issue to document the plan and to use in cleaning up various other issues. csevb10 will actually drupalorg_order_facet and turn it into a patch for this.
Cheers,
-Derek
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 867312-3.apachesolr_result_block.patch | 5.66 KB | dww |
| #2 | 867312-3.apachesolr_result_block.interdiff.txt | 3.8 KB | dww |
| #1 | apachesolr-868794.patch | 4.79 KB | csevb10 |
Comments
Comment #1
csevb10 commentedAttached is a patch changing drupalorg_order_facet to apachesolr_result_block in the contrib section of apachesolr.
Let me know if there is anything you would like changed, improved, etc.
Thanks!
--Bill
Comment #2
dwwI rerolled this for a few things. New patch and interdiff attached. Summary of changes:
A) Fixed the .info file to indicate this is now an Apache Solr thing, not drupal.org. ;)
B) Removed references to the "order facets" terminology -- we're calling these "result blocks" now.
C) Broke up this giant conditional and gave it some comments:
D) Changed _apachesolr_result_block_build() from a private helper function into a public-facing API function apachesolr_result_block_results() -- that basically solves #666120: Provide API to get the top N projects for various categories while we're at it. Added PHPDoc block for it to document the params (as best as I understand them, this might still need some refinement).
E) Made the appearance of the "More X" link controlled by another optional param.
F) Simplified the return code. Either way, when we're done, we can just return $items, since that array will either have the results or be empty.
I still have a question if the response object should be a parameter to this function, or if this function should just call apachesolr_static_response_cache() itself. I don't know enough about Solr to have a strong feeling, but it seems like everyone calling this is going to want that behavior. I left it as-is for now, but I'd be happy to see it changed if the Solr experts thought that'd be better.
Otherwise, assuming this actually works (the only "testing" I did was php -l), I think this is RTBC.
Thanks, Bill!
-Derek
Comment #3
dww- There was a bug in part (D) of my reroll, since I missed a spot in the rename to apachesolr_result_block_results()
- Furthermore, pwolanin, csevb10 and I discussed this issue in some detail in IRC and there are some deeper problems here. There's lots of confusion still over what's a "facet" and what's a sortable field. Furthermore, the underlying plumbing is wonky with how we're trying to reuse the active facets from the parent search. I'll leave it to pwolanin to clarify, but he and csevb10 had some good ideas on ways to make apachesolr itself more suited to handling this sort of thing (in ways that have implications for multi-site search which I don't fully understand). ;)
So, this is not at all close to RTBC in its current state... Therefore, we're not going to try to push this out to redesign.d.o tonight. ;)
Comment #4
dwwWe should also fix #875598: Lack of standard prefix on "order facet" blocks makes them very hard to work with before this lands in apachesolr...
Comment #5
jpmckinney commentedI assume the redesign is using this module. I don't especially want to add more submodules.