Index: apachesolr.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.admin.inc,v
retrieving revision 1.1.2.17
diff -u -p -r1.1.2.17 apachesolr.admin.inc
--- apachesolr.admin.inc	6 May 2009 16:34:19 -0000	1.1.2.17
+++ apachesolr.admin.inc	6 May 2009 22:18:35 -0000
@@ -190,6 +190,24 @@ function apachesolr_enabled_facets_form_
   $enabled = array();
   foreach ($form_state['values']['apachesolr_enabled_facets'] as $module => $facets) {
     $enabled[$module] = array_filter($facets);
+    
+    /**
+     * Set taxonomy module to be apachesolr_search for vocabularies from enabled facets
+     * This will get term paths from apachesolr_search_term_path() instead of taxonomy.
+     */
+    if ($module == "apachesolr_search") {
+      foreach ($facets as $delta => $selected) {
+        if (substr($delta, 0, 7) == "im_vid_") {
+          $vid = substr($delta, 7);
+          if ($selected) {
+            $handler = $module;
+          } else {
+            $handler = "taxonomy";
+          }
+          db_query("UPDATE {vocabulary} SET module = '%s' WHERE vid = %d", $handler, $vid);
+        }
+      }
+    }
   }
   variable_set('apachesolr_enabled_facets', $enabled);
   drupal_set_message($form_state['values']['submit_message'], 'warning');
Index: apachesolr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v
retrieving revision 1.1.2.12.2.139
diff -u -p -r1.1.2.12.2.139 apachesolr.module
--- apachesolr.module	6 May 2009 16:34:19 -0000	1.1.2.12.2.139
+++ apachesolr.module	6 May 2009 22:18:36 -0000
@@ -1012,6 +1012,18 @@ function apachesolr_drupal_query($keys =
   list($module, $class) = variable_get('apachesolr_query_class', array('apachesolr', 'Solr_Base_Query'));
   include_once drupal_get_path('module', $module) .'/'. $class .'.php';
   
+  /**
+   * This allows the user to issue filters within keyword searches by placing them in brackets
+   * Examples: 
+   *  "bike [filters=tid:1]" would return items matching "bike" filtered by term ID 1
+   *  "* [filters=tid:1]" would return all items that have term ID 1
+   */
+  if (preg_match('/.*\[filters=([^\]]+)/', $keys, $matches)) {
+    $filters = $matches[1];
+    // Remove [filter=...] from $keys so Solr doesn't try to search for it as keywords
+    $keys = preg_replace('/ *\[filters=.*?\] */', '', $keys);
+  }
+
   try {
     $query = new $class(apachesolr_get_solr(), $keys, $filters, $solrsort, $base_path);
   }
Index: apachesolr_search.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr_search.module,v
retrieving revision 1.1.2.6.2.90
diff -u -p -r1.1.2.6.2.90 apachesolr_search.module
--- apachesolr_search.module	6 May 2009 01:15:35 -0000	1.1.2.6.2.90
+++ apachesolr_search.module	6 May 2009 22:18:36 -0000
@@ -598,6 +598,12 @@ function apachesolr_search_get_type($fac
  */
 function apachesolr_search_form_search_form_alter(&$form, $form_state) {
 
+  // Remove filter commands from keywords, like "[filter=tid:12345]"
+  if ($form['module']['#value'] == 'apachesolr_search') {
+    $keys = preg_replace('/ *\[filters=.*?\] */', '', $form['basic']['inline']['keys']['#default_value']);
+    $form['basic']['inline']['keys']['#default_value'] = $keys;
+  }
+
   if (($form['module']['#value'] == 'apachesolr_search') && variable_get('apachesolr_search_spellcheck', FALSE) && apachesolr_has_searched() && ($response = apachesolr_static_response_cache())) {
     //Get spellchecker suggestions into an array.
     $suggestions = get_object_vars($response->spellcheck->suggestions);
@@ -761,3 +767,23 @@ function theme_apachesolr_currentsearch(
 function theme_apachesolr_search_snippets($doc, $snippets) {
   return implode(' ... ', $snippets);
 }
+
+/**
+ * Implementation of taxonomy_term_path.
+ *
+ * This rewrites taxonom term links for filters enabled in admin/settings/apachesolr/enabled-filters
+ */
+function apachesolr_search_term_path($term) {
+  static $vids_to_override;
+  
+  if (!isset($vids_to_override)) {
+    $vids_to_override = apachesolr_get_enabled_facets('apachesolr_search');
+  }
+  $vocabulary_facet_name = 'im_vid_' . $term->vid;
+  if (in_array($vocabulary_facet_name, $vids_to_override)) {
+    // apachesolr_current_query() accepts filters on keyword searches using syntax [filters=tid:XX]
+    return 'search/apachesolr_search/[filters=tid:' . $term->tid . ']';
+  } else {
+    return 'taxonomy/term/' . $term->tid;
+  }
+}
