There is a pending change at #1252644: Remove assumption that the facets will link back to the page they are on that could effect Facet API integration. In order to maintain backwards compatibility with the Apache Solr and Faceted Navigation for Search projects, I have to default to an implementation that works with those two solutions. Search API's adapter will need to override FacetapiAdapter::getSearchPath() in order to set the correct path for the search.

CommentFileSizeAuthor
#3 search_api-1263386-3.patch628 bytescpliakas
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cpliakas’s picture

Question to Thomas...

In terms of the Search API module, what is the best way to get the base path for the search? Any guidance you can give as to which API functions are available would be helpful.

Thanks,
Chris

drunken monkey’s picture

In terms of the Search API module, what is the best way to get the base path for the search?

Basically, there is none. There isn't even a method to find all searches defined on a site, let alone where they are or how they pass the search keys.
Apart from defaulting to $_GET['q'], I think the only thing we could do here (if this is important to differentiate) is allowing to override this default via a certain query object option (which, e.g., Search pages could then use).
But how would that work? Would facets then link to that base path plus their GET parameter? Then $_GET['q'] would be correct in all current cases anyways – save for the "Facets block" Views display which I'll have to hack together anyways, probably.

cpliakas’s picture

Status: Active » Needs review
FileSize
628 bytes

GET['q'] is perfectly fine. The use case for getting the path is the case where facets should be displayed on the home page to initiate a search. Definitely not required, and something that the Search API module would have to do the heavy lifting for if this functionality were to be added later. Refer to the patch against Apache Solr at #1252648: Allow for enabling facet blocks on non-search pages for an example.

I attached a very complex, mind bending patch for this.

Thanks,
Chris

drunken monkey’s picture

Status: Needs review » Reviewed & tested by the community

Woah, awesome work! I don't think I grasp all of this in full detail, but what I can understand looks fine. Extensive testing also showed no bugs, so this should be RTBC.

And yeah, we can go back and add some other mechanism in there later, if we can come up with something. The Views „Facets block“ display actually does this, but I think it'll be easier to code the facet listing myself for that.
Hm, or maybe I'll edit that then and really introduce a base path query option. This would allow you to just activate the facet blocks you want and be done with it …

cpliakas’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the feedback. Committed at e361465.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.