I needed to understand myself, so created this patch to save other the trouble. Patch adds to the README 5 example of different ways to craft a url.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey’s picture

Category: task » feature
FileSize
2.38 KB

Ah, thanks, good idea! Most people first encountering this have been confused up to now, and I haven't really done a good job of clearing up that confusions. So maybe this will help.

However, regarding the content: Have these really worked for you? As far as I can tell, only the last example is correct, although I can imagine some of the others working as the module tries to find a reasonable fallback. Sorry to put you through the whole guesswork, it really seems I need better documentation. :-/
The attached patch should contain correct examples, I've also changed some formulations. Also, I don't think listing the direct URL is the best way to go, as the URL escaping (which also would have to be applied to the brackets, to be completely correct) makes it rather hard to read. On the other hands, we can't really count on all site builders knowing about url()/l(), right? So maybe a mixed version? Even people not knowing the functions might be reliefed to see the unescaped values, too.

On a different note, #1182614: Integrate with Facet API will soon change the way facets are handled. The syntax for them will probably stay the same, though, so probably only minor corrections will be necessary. However, it will have to be moved to another file, as the whole Facets module will later be removed (after a transitional period of some months).

amitaibu’s picture

> Have these really worked for you? As far as I can tell, only the last example is correct

They actually do, I did it actually based on reading search_api_facets_search_api_query_alter() and _search_api_create_filter_name().

Indeed your example is more clear, and it's a good idea to document how to use url/ l().
I think we should also mention the possibility of "any" (i.e. + $options['query']['filter']['field_price'][] = '"*';)

drunken monkey’s picture

FileSize
5.5 KB

I think we should also mention the possibility of "any" (i.e. + $options['query']['filter']['field_price'][] = '"*';)

The filter should actually be '(* *)', I think. I don't know why these should work for you, especially after looking at the code.
As written in my patch, the possible values for filters are listed in the documentation of SearchApiFacetsQueryInterface::execute(), in the .api.php file.

drunken monkey’s picture

amitaibu’s picture

I'll revisit my code on Sunday, to see how come it worked. Anyway, your patch looks good and clear.

drunken monkey’s picture

Status: Needs review » Fixed

I guess it doesn't really matter. The correct versions work fine, as far as I can tell, and as the behaviour of incorrect filters can be seen as unspecified, I guess it's alright if they, for some reason, work too. *shrug*

Anyways, thanks for the suggestion! Committed.
I hope I could also help you a little with your understanding of facets and their URLs. Feel free to ask if things are still unclear.

Status: Fixed » Closed (fixed)

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