How can I shorten Facet API urls programatically? My site uses Search API and Facet API for search.

My user search has several entity references that are also indexed.  So, when just two facets are activated, this gives me a URL like this:

http://www.example.com/search&amp;f1=field_acc_gen%253Afield_location_taxonomize_terms%3A885&amp;f2=field_acc_gen%253Afield_languages%3A50

This is way too long.  What I'd like to do is collapse the field_acc_gen%253Afield_location_taxonomize_terms to co (country) and field_acc_gen%253Afield_languages%3A50 to la (language).

I know that Facet API Pretty Paths can be used to shorten the URLs but because I have about 20 facets, the regex that it uses seems to really kill performance.  I am also thinking about using Search API Page, which does not work with FacetAPI Pretty Paths.  So, I was hoping to find a way to rename the facets themselves in code.

I have my facets exported using the Features module.  I tried changing $facet-&gt;name, but this had no affect on the results:

  $facet-&gt;name = 'search_api@om_user_search::field_acc_gen:field_language';
  $facet-&gt;searcher = 'search_api@om_user_search';
  $facet-&gt;realm = '';
  $facet-&gt;facet = 'field_acc_gen:field_language';


to:

  $facet-&gt;name = 'search_api@om_user_search::la';


How can I programmatically rename a facet?
You want facetapi_alias.

The facets already have a setting "facet alias" internally, which can be different from the facet machine name.
But this setting is not exposed in the UI natively.

The FacetAPI Alias module simply exposes this setting on the facet display form.

If you want more advanced solutions, you could use facetapi pretty paths (as you mentioned), or write your own FacetapiUrlProcessor. I have done the latter, and I can tell you it was painful :)