diff --git a/contrib/search_api_views/includes/query.inc b/contrib/search_api_views/includes/query.inc
index bc9af4d..4394c5f 100644
--- a/contrib/search_api_views/includes/query.inc
+++ b/contrib/search_api_views/includes/query.inc
@@ -310,6 +310,9 @@ public function build(&$view) {
     if (!empty($this->view->override_path) && strpos(current_path(), $this->view->override_path) !== 0) {
       $this->query->setOption('search_api_base_path', $this->view->override_path);
     }
+
+    // Save query information for Views UI.
+    $view->build_info['query'] = (string) $this->query;
   }
 
   /**
diff --git a/includes/query.inc b/includes/query.inc
index debed66..086ab42 100644
--- a/includes/query.inc
+++ b/includes/query.inc
@@ -856,10 +856,33 @@ public function __toString() {
       }
       $ret .= 'Sorting: ' . implode(', ', $sort) . "\n";
     }
-    $ret .= 'Options: ' . str_replace("\n", "\n  ", var_export($this->options, TRUE)) . "\n";
+    $options = $this->sanitizeOptions($this->options);
+    $options = str_replace("\n", "\n  ", var_export($options, TRUE));
+    $ret .= 'Options: ' . $options . "\n";
     return $ret;
   }
 
+  /**
+   * Sanitizes an array of options in a way that plays nice with var_export().
+   *
+   * @param array $options
+   *   An array of options.
+   *
+   * @return array
+   *   The sanitized options.
+   */
+  protected function sanitizeOptions(array $options) {
+    foreach ($options as $key => $value) {
+      if (is_object($value)) {
+        $options[$key] = 'object (' . get_class($value) . ')';
+      }
+      elseif (is_array($value)) {
+        $options[$key] = $this->sanitizeOptions($value);
+      }
+    }
+    return $options;
+  }
+
 }
 
 /**
