Index: apachesolr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v
retrieving revision 1.1.2.35
diff -u -p -r1.1.2.35 apachesolr.module
--- apachesolr.module   18 Sep 2008 07:07:27 -0000      1.1.2.35
+++ apachesolr.module   19 Sep 2008 15:10:22 -0000
@@ -368,14 +368,21 @@ class ApacheSolrUpdate {
           
           if (is_array($node->taxonomy)) {
             foreach ($node->taxonomy as $term) {
-              $document->setMultiValue('tid', $term->tid);
-              
               // Double indexing of tids lets us do effecient searches (on tid)
               // and do accurate per-vocabulary faceting.
-              $document->setMultiValue('imfield_vid' . $term->vid, $term->tid);
               
-              $document->setMultiValue('vid', $term->vid);
-              $document->setMultiValue('taxonomy_name', $term->name);
+              // By including the ancestors to a term in the index we make 
+              // sure that searches for general categories match specific
+              // categories, e.g. Fruit -> apple, a search for fruit will find
+              // content categorized with apple.
+              $ancestors = taxonomy_get_parents_all($term->tid);    
+              foreach ($ancestors as $ancestor) {
+                $document->setMultiValue('tid', $ancestor->tid);
+                $document->setMultiValue('imfield_vid'. $ancestor->vid, $ancestor->tid);
+                $document->setMultiValue('vid', $ancestor->vid);
+                $document->setMultiValue('taxonomy_name', $ancestor->name);
+                $text .= ' ' . $ancestor->name;
+              }
             }
           }
           $document->text = $text;
