Index: Solr_Base_Query.php
===================================================================
RCS file: /cvs/drupal/contributions/modules/apachesolr/Solr_Base_Query.php,v
retrieving revision 1.1.4.16
diff -u -r1.1.4.16 Solr_Base_Query.php
--- Solr_Base_Query.php	18 Dec 2008 08:48:44 -0000	1.1.4.16
+++ Solr_Base_Query.php	21 Dec 2008 09:40:22 -0000
@@ -12,16 +12,17 @@
    * Extract a module-specific search option from a search query. e.g. 'type:book'
    */
   static function query_extract($filters, $option) {
-    $pattern = '/(^| )'. $option .':(\"([^\"]*)\")/i';
-    preg_match_all($pattern, $filters, $matches);
-    if (!empty($matches[2])) {
-      // The preg_replace removes beginning and trailing quotations.
-      return preg_replace('/^"|"$/', '', $matches[2]);
-    }
-    $pattern = '/(^| )'. $option .':([^ ]*)/i';
-    if (preg_match_all($pattern, $filters, $matches)) {
-      if (!empty($matches[2])) {
-        return $matches[2];
+    $patterns = array(
+      '(?:\[|{)[^ ]+ TO [^ ]+(\]|})' => FALSE, // range queries
+      '\"([^\"]*)\"' => TRUE,
+      '[^ ]*' => FALSE,
+    );
+    
+    foreach ($patterns as $pattern => $remove_quotations) {
+      if (preg_match_all('/(^| )'. $option .':('. $pattern .')/i', $filters, $matches)) {
+        if (!empty($matches[2])) {
+          return $remove_quotations ? preg_replace('/^"|"$/', '', $matches[2]) : $matches[2];
+        }
       }
     }
   }
@@ -50,8 +51,9 @@
       return implode(' ', array_filter(explode(' ', $values['#value']), 'trim'));
     }
     else {
-      // if the field value has spaces, or : in it, wrap it in double quotes.
-      if (preg_match('/[ :]/', $values['#value'])) {
+      // if the field value has spaces, or : in it and it's not a range query,
+      // wrap it in double quotes.
+      if (preg_match('/[ :]/', $values['#value']) && !preg_match('/^(?:\[|{)[^ ]+ TO [^ ]+(\]|})$/', $values['#value'])) {
         $values['#value'] = '"'. $values['#value']. '"';
       }
       return $values['#name']. ':'. $values['#value'];

