Can you tag individual searches per search in order to apply different filters to each? I've got a site where we use solr to generate some menu items and other custom lists as well as running the default search. The issue I'm running in to is all the different hook_apachesolr_query_alter calls across several different modules seem to be getting applied on top of each other stopping everything from working as expected.

Is there an identifier I can look for, or that I can add, in order to identify which query is currently being altered so I can filter them appropriately?

This is what I want to be able to do:

&lt;?php
if ($query-&gt;name == 'special_menu'){
  $query-&gt;replaceParam('qf', 'sm_vid_Colour');
}
?&gt;


(This is a dupe of my post on Drupal.org at http://drupal.org/node/1976224 but I wasn't getting any love there and thought I'd try my luck here!)
I found a solution that worked for me. Here it is in case anyone else wants to do something similar, or in case someone wants to suggest a better way of doing it!

So the situation is that for a single page, I need to run a handful of SOLR queries to determine what should show up and what should not. Each of those queries works on different fields, so we need to be able to add a different 'qf' parameter to each of them. This gets harder however, when all hook_apachesolr_query_alter calls trigger on all searches! (See the related issue about enabling 'qf' #1659184: Allow apachesolr_search_search_results() to accept 'qf' (query fields) parameter)

After a lot of experimentation I found that the only field I could manipulate when starting a query and fetch and act on in hook_apachesolr_query_alter was using the search path value in a custom $search_page. This is how I did it:

&lt;?php
$search_page = array(
        'env_id'   =&gt; 'solr_server',
        'settings' =&gt; array(
          'apachesolr_search_per_page' =&gt; 25,
          'spellcheck' =&gt; FALSE,
        ),
        'search_path' =&gt; 'ducks-BiGhE3Nxv34lyTKVoka74WI3r9yjJyc5ohiuJkeCiqp8gJunyWk3gXMDK8W',
      );

      $search_terms = array('"duck"', '"cheese sauce"');

      // Only run if the solr is enabled server environment is detected.
      if (module_exists('apachesolr') &amp;&amp; apachesolr_environment_load($search_page['env_id'])) {
        $results = apachesolr_search_search_results('"' . implode(' ', $search_terms). '"', NULL, $search_page);
?&gt;


Then, in hook_apachesolr_query_alter for this particular module/query:

&lt;?php
function pet_or_dinner_apachesolr_query_alter($query) {
  /* test that this is a 'ducks' query */
  if (stristr($query-&gt;getPath(), 'ducks')){
    /* now apply different settings depending on the current page */
    $node = menu_get_object();
    if (isset($node-&gt;type) &amp;&amp; $node-&gt;type == 'pets') {
      //Search only the Pet field
      $query-&gt;replaceParam('qf', 'sm_vid_pet');
    } elseif (isset($node-&gt;type) &amp;&amp; $node-&gt;type == 'meals') {
      //Search only the Meal field
      $query-&gt;replaceParam('qf', 'sm_vid_meal');
    }
  }
}
?&gt;


I don't know if it's necessary, but I put the extra long random string in the 'search_path' so that I didn't have any site visitors accidentally tripping over it. I don't think it is publicly accessible though. Someone else can confirm or debunk that concept!

But there we go, a hook to be able to perform custom modifications on concurrent queries. Definitely not clean but it gets us over the line!

I'll leave this question open in case someone has a better answer.