I wanted to chime in here as I found an alternative way of using Rules to do this.
Plus I feel what I have spent the past 3 days trying to figure out is similar and Johnathan's edited answer led me in the right direction to solve my issue.
How to redirect to a custom search page with facets ( a custom panel in my case ) from the default search block when using Search API w/ Solr and pre-fill the exposed filter with the term searched for by the user.
Install the Custom Search module.
Use the Custom Search module to do turn on a custom search path to something unique like "mysearch/[key]" the [key] will extract the search term used in the default search box.
Next Use Rules to catch the custom path used by Custom Search, extract the search term(s), redirect where you want to end up, and, most importantly, pre-fill any facets or exposed filters with the "?filter_name=variable" appended to the path.
EDIT:
Go to Rules
-> Add New Rule
-> React on event -> Drupal is initializing
-> Add Condition -> Execute custom PHP code:
$arg0 = arg(0);
if ($arg0 == 'mysearch') {
return true;
}
-- This is to catch the custom search path created with the custom search module above so we only apply the action to someone searching in the default search box.
Add Action -> Page redirect:
search/products?search_api_views_fulltext=<?php $arg1 = arg(1); print_r($arg1); ?>
-- You can fill in the query string variables with your facet names or search box ( like I did ) and use the PHP code to extract the incoming arguments you want to pass on to the search page so the facet/search box will be filled in correctly.
-- "search_api_views_fulltext" is the name of the exposed filter ( the search box in this case )
The issue I ran into was when I had a facet field that was referenced through the main node. These show up in the Facets Tab like "Product Reference » Status" after adding an additional field to the index on the Fields Tab.
The URL for the Facet was returning { facet_field_name=%253ASelected_facet }. What should be a " : " that is URL encoded as " %3A " is being displayed as " %253A " but only for those fields that are referenced through, not the facets connected directly to the main node. The redirect part fails here and you are unable to pre-select the facet. You can create a manual link in the menu system with the " %253A " and everything works, its just the redirect. I have no answer for this one, so I moved all my facets to the main node and it works just fine.
I hope this helps.