Hello and thanks a lot for this great module.
I have to create new facets to filter content from many sites, Drupal and non-Drupal, stored in the same SORL index. The indexation part is working, and the results conform to what's expected (search fields, sensible results, existing facets are OK, etc.)
Examining the code of the module, I don't understand how I can hook in it to add my own facets.
In fact, I don't really understand why the facet management is separated from the regular monosite search of the apachesolr module.
Could you please enlighten me and point me in the right direction ?
Comments
Comment #1
Countzero commentedWell, I made some progress. Sort of.
I modified the file apachesolr_multisitesearch.admin.inc to include this :
in function apachesolr_multisitesearch_enabled_facets_form().
I managed to add a facet to the admin screen at admin/settings/apachesolr/multisite-filters by implementing the new hook in my module :
My facet appears in a frame named after my module name, which is fine.
Then I tried to implement hook_block to manage the block which should match my facet (I pasted and modified a bit from the base module) :
... and my block appears in admin/build/block.
It also appears in the search results, but as for now, the result count doesn't make sense (251 results out of 8). I guess it's because I didn't implement _add_facet_params yet.
So it's my next step. I'll keep this thread updated as I go, but any help would speed up my efforts and would be appreciated.
Thanks for reading and see you soon.
Comment #2
Countzero commentedIn fact, the inconsistency came from a faulty index.
So my facet works except that a click on any item in it results in no result whatever the value.
Also, querying directly in SOLR with :
... seems to return the expected results, so I'm pretty sure my code is to blame.
I'm stuck.
Comment #3
Countzero commentedOK, got it working.
I implemented a function to handle my facet, and use a numeric value to filter the results, and it seems to work (I got inspired by, and effectively copied the code from, this http://drupal.org/files/issues/apachebook_0.patch) :
I changed this line in the hook_block above :
to :
and of course coded - copied - this function :
... and tadaaaa ! Everything's fine.
My mistake was to think there was some kind of automatic handling of the values, which is not the case, at least in this precise use case.
Now, on the road again to code my other facets.
Comment #4
Countzero commentedOne bug remains : the unclick link for the facets show the id and not the text. Don't see how I can fix this as for now.
As usual (but is anybody reading this ?), any help would be appreciated.
Comment #5
Countzero commentedSolved.
I had to implement the theme functions for my facets :
I had to use the namespace of the original apachesolr module, because of this in the apachesolr_multisitesearch_currentsearch function :
If I make a patch for the module, I think I will try to enhance it to allow modules to namespace their theme functions.
Comment #6
Countzero commentedI had a lot of trouble because of a tweaked schema.xml. Also, keep in mind that reindexing is not enough to take changes to schema.xml into account.
YOU HAVE TO RELOAD TOMCAT TO LOAD A NEW VERSION OF SCHEMA.XML.
It would have saved me a few hours of stress if I had known this before.
My work with this module is almost finished. I don't know if a handbook summarizing what I learned in the process would be of interest ? Given the numerous reactions to my posts since last week, I find myself doubting ...
Comment #7
pwolanin commented@Countzero - any addition to the documentation is appreciated.
I just added a documentation stub - please add child pages here: http://drupal.org/node/828468
Comment #8
Countzero commentedNoted.
I'll try to write something as clear as possible before the end of the week.
Comment #9
Countzero commentedHere's the page : http://drupal.org/node/829148.
Hope I didn't left too many mistakes.
Comment #10
Countzero commentedComment #11
csevb10 commentedI've actually created the patch for this because I feel like the ability to add your own facets should exist without having to patch the file yourself.
This creates an apachesolr_multisitesearch_facets() hook so that any module can implement multisitesearch facets. It also simplifies the code logic to remove the hard-coded case for apachesolr_multisitesearch module and makes the invocation in apachesolr_multisitesearch an implementation of hook_apachesolr_multisitesearch_facets().
Comment #12
pwolanin commentedI find calling your own hook a bit ugly, but maybe it's the easiest approach.
previous patch misses a function call in hook_bock that needs to change. Also, I'm not sure function _apachesolr_sort_facets would exist in memory. In any case it's a private function that should not be called by another module.
Comment #13
pwolanin commentedcommitted to HEAD after a little local testing.