Index: handlers/apachesolr_views_handler_field_userreference.inc
===================================================================
--- handlers/apachesolr_views_handler_field_userreference.inc	(revision 0)
+++ handlers/apachesolr_views_handler_field_userreference.inc	(revision 0)
@@ -0,0 +1,27 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * provides a field handler for the snippet coming from the ApacheSolr search engine
+ */
+class apachesolr_views_handler_field_userreference extends views_handler_field {
+  function query() {
+    $this->query->add_field($this->real_field);
+  }
+
+  function render($doc) {
+    if (is_array($doc->{$this->real_field})) {
+      $values = $doc->{$this->real_field};
+    }
+    else {
+      $values = array($doc->{$this->real_field});
+    }
+    
+    $names = array();
+    foreach ($values as $uid) {
+      $names[] = db_result(db_query('SELECT name FROM {users} WHERE uid = %d', $uid));
+    }
+    return implode(', ', $names);
+  }
+}
Index: handlers/apachesolr_views_handler_filter_userreference.inc
===================================================================
--- handlers/apachesolr_views_handler_filter_userreference.inc	(revision 0)
+++ handlers/apachesolr_views_handler_filter_userreference.inc	(revision 0)
@@ -0,0 +1,254 @@
+<?php
+// $Id$
+
+/**
+ * Class for filtering by userreference uid.
+ */
+class apachesolr_views_handler_filter_userreference extends content_handler_filter_many_to_one {
+
+  public function query() {
+
+    $not = $this->operator == 'not in';
+    $uids = (array)$this->value;
+
+    if (empty($uids)) {
+      if (!$not) {
+        $this->query->add_filter($this->real_field, apachesolr_views_query::escape_term('-1'));
+      }
+    }
+    else {
+      foreach ($uids as $uid) {
+        $filter_string .= " OR $uid";
+      }
+      
+      // Construct a small subquery.
+      $filter_string = substr($filter_string, 4);
+      $filter_string = "($filter_string)";
+
+      // Add it to the query.
+      $this->query->add_filter($this->real_field, $filter_string, $not);
+    }
+  }
+
+  function has_extra_options() {
+    return TRUE;
+  }
+
+  function option_definition() {
+    $options = parent::option_definition();
+    $options['type'] = array('default' => 'textfield');
+    return $options;
+  }
+
+  function extra_options_form(&$form, &$form_state) {
+    $form['markup_start'] = array(
+      '#value' => '<div class="views-left-40">',
+    );
+    $form['type'] = array(
+      '#type' => 'radios',
+      '#title' => t('Selection type'),
+      '#options' => array('select' => t('Dropdown'), 'textfield' => t('Autocomplete')),
+      '#default_value' => $this->options['type'],
+    );
+    $form['markup_end'] = array(
+      '#value' => '</div>',
+    );
+  }
+
+  /**
+   * Get allowed values from hook_allowed_values(), if any, or from
+   * content_allowed_values();
+   */
+  function allowed_values() {
+    $options = userreference_allowed_values(content_fields($this->definition['cck_field']['field_name']));;
+    return (array) $options;
+  }
+
+  function value_form(&$form, &$form_state) {
+    $form['value'] = array();
+    
+    if ($this->options['type'] == 'select') {
+      $this->get_value_options();
+      $options = $this->value_options;
+      $default_value = (array) $this->value;
+
+      $which = 'all';
+      if (!empty($form['operator'])) {
+        $source = ($form['operator']['#type'] == 'radios') ? 'radio:options[operator]' : 'edit-options-operator';
+      }
+      if (!empty($form_state['exposed'])) {
+        $identifier = $this->options['expose']['identifier'];
+
+        if (empty($this->options['expose']['use_operator']) || empty($this->options['expose']['operator'])) {
+          // Exposed and locked.
+          $which = in_array($this->operator, $this->operator_values(1)) ? 'value' : 'none';
+        }
+        else {
+          $source = 'edit-' . form_clean_id($this->options['expose']['operator']);
+        }
+
+        if (!empty($this->options['expose']['reduce'])) {
+          $options = $this->reduce_value_options();
+
+          if (empty($this->options['expose']['single']) && !empty($this->options['expose']['optional'])) {
+            $default_value = array();
+          }
+        }
+
+        if (!empty($this->options['expose']['single'])) {
+          if (!empty($this->options['expose']['optional']) && (empty($default_value) || !empty($this->options['expose']['reduce']))) {
+            $default_value = 'All';
+          }
+          else if (empty($default_value)) {
+            $keys = array_keys($options);
+            $default_value = array_shift($keys);
+          }
+          else {
+            $copy = $default_value;
+            $default_value = array_shift($copy);
+          }
+        }
+      }
+
+      if ($which == 'all' || $which == 'value') {
+        if ($this->value_form_type == 'checkboxes') {
+          foreach ($options as $key => $option) {
+            $options[$key] = check_plain($option);
+          }
+        }
+        $form['value'] = array(
+          '#type' => $this->value_form_type,
+          '#title' => $this->value_title,
+          '#options' => $options,
+          '#default_value' => $default_value,
+          // These are only valid for 'select' type, but do no harm to checkboxes.
+          '#multiple' => TRUE,
+          '#size' => count($options) > 8 ? 8 : count($options),
+          '#pre_render' => array('apachesolr_views_handler_filter_cleanup'),
+        );
+        
+        if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier])) {
+          $form_state['input'][$identifier] = $default_value;
+        }
+
+        if ($which == 'all') {
+          $process = array();
+          if ($this->value_form_type == 'checkboxes' || $this->value_form_type == 'radios') {
+            $process[] = "expand_$this->value_form_type";
+            $form['value']['#prefix'] = '<div id="edit-options-value-wrapper">';
+            $form['value']['#suffix'] = '</div>';
+          }
+          $process[] = 'views_process_dependency';
+          $form['value'] += array(
+            '#process' => $process,
+            '#dependency' => array($source => $this->operator_values(1)),
+          );
+        }
+      }
+
+      if (empty($form_state['exposed'])) {
+        $this->helper->options_form($form, $form_state);
+      }
+    }
+    elseif ($this->options['type'] == 'textfield') {
+      $default = '';
+      if (is_numeric($this->value)) {
+        $default = check_plain(db_result(db_query('SELECT name FROM {users} WHERE uid = %d', $this->value)));
+        if ($this->options['expose']['show_uid']) {
+          $default .= ' [uid:' . $this->value . ']';
+        }
+      }
+      else {
+        $default = $this->value;
+      }
+      
+      $form['value'] = array(
+        '#title' => $this->value_title,
+        '#type' => 'textfield',
+        '#default_value' => $default,
+      );
+      if ($this->options['expose']['show_uid']) {
+        $form['value']['#autocomplete_path'] = 'userreference/autocomplete/'. $this->definition['cck_field']['field_name'];
+      }
+      else {
+        $form['value']['#autocomplete_path'] = 'apachesolr-views/userreference/autocomplete/'. $this->definition['cck_field']['field_name'];
+      }
+    }
+  }
+
+  function value_validate(&$form, &$form_state) {
+    // We only validate if they've chosen the text field style.
+    if ($this->options['type'] != 'textfield') {
+      return;
+    }
+
+    $uid = $this->userreference_validate($form, $form_state['values']['options']['value']);
+
+    $form_state['values']['options']['value'] = $uid;
+  }
+
+  function exposed_validate(&$form, &$form_state) {
+    if (empty($this->options['exposed'])) {
+      return;
+    }
+
+    $identifier = $this->options['expose']['identifier'];
+
+    // We only validate if they've chosen the text field style.
+    if ($this->options['type'] != 'textfield') {
+
+      if ($form_state['values'][$identifier] != 'All')  {
+        $this->validated_exposed_input = (array) $form_state['values'][$identifier];
+      }
+      return;
+    }
+
+    if (empty($this->options['expose']['identifier'])) {
+      return;
+    }
+    $uid = $this->userreference_validate($form, $form_state['values'][$identifier]);
+    $this->validated_exposed_input = $uid;
+    $form_state['values'][$identifier] = $uid;
+  }
+
+  function userreference_validate(&$form, $value) {
+    $field = content_fields($this->definition['cck_field']['field_name']);
+    if (!empty($value)) {
+      preg_match('/^(?:\s*|(.*) )?\[\s*uid\s*:\s*(\d+)\s*\]$/', $value, $matches);
+      if (!empty($matches)) {
+        // Explicit [uid:n].
+        list(, $title, $uid) = $matches;
+        if (!empty($title) && ($n = user_load($uid)) && $title != $n->name) {
+          form_error($form['value'], t('%name: title mismatch. Please check your selection.', array('%name' => t($field['widget']['label']))));
+        }
+      }
+      else {
+        // No explicit uid.
+        $reference = _userreference_potential_references($field, $value, 'equals', NULL, 1);
+        if (empty($reference)) {
+          form_error($form['value'], t('%name: found no valid post with that title.', array('%name' => t($field['widget']['label']))));
+        }
+        else {
+          $uid = key($reference);
+        }
+      }
+    }
+
+    return $uid;
+  }
+
+  function expose_options() {
+    parent::expose_options();
+    $this->options['expose']['show_uid'] = TRUE;
+  }
+
+  function expose_form_right(&$form, &$form_state) {
+    parent::expose_form_right($form, $form_state);
+    $form['expose']['show_uid'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Show uid in text field'),
+      '#description' => t('If checked, the autocomplete field will contain the node id. This can yield more accurate results.'),
+      '#default_value' => !empty($this->options['expose']['show_uid']),
+    );
+  }
+}
Index: handlers/apachesolr_views_handler_argument_nodereference.inc
===================================================================
--- handlers/apachesolr_views_handler_argument_nodereference.inc	(revision 0)
+++ handlers/apachesolr_views_handler_argument_nodereference.inc	(revision 0)
@@ -0,0 +1,136 @@
+<?php
+
+/**
+ * @file
+ * Provides an argument handler for nodereferences
+ */
+class apachesolr_views_handler_argument_nodereference extends content_handler_argument_many_to_one {
+
+  var $value;
+
+  function construct() {
+    parent::construct();
+
+    $this->content_field = content_fields($this->definition['cck_field']['field_name']);
+
+  }
+
+  function query() {
+    $argument_values = $this->get_value();
+    $allowed_arguments = $this->allowed_values();
+
+    if (!empty($this->options['break_phrase'])) {
+      $passed_arguments = explode(',', $argument_values);
+    }
+    else {
+      $passed_arguments = array($argument_values);
+    }
+
+    // check passed arguments against allowed values
+
+    $valid_arguments = array();
+
+    foreach ($passed_arguments as $value) {
+
+      if (array_key_exists($value, $allowed_arguments)) {
+        $valid_arguments[] = (int) $value;
+      }
+
+    }
+
+    if(!empty($valid_arguments)) {
+
+      foreach ($valid_arguments as $facet_value) {
+        $this->query->add_filter($this->real_field, apachesolr_views_query::escape_term($facet_value));
+      }
+
+    }
+    else {
+      $this->query->add_filter($this->real_field, apachesolr_views_query::escape_term('-1'));
+    }
+
+  }
+
+  /**
+   * Get the title this argument will assign the view, given the argument.
+   */
+  function title() {
+    $options = $this->title_query();
+    return $options[0];
+  }
+
+  /**
+   * Get allowed values from hook_allowed_values(), if any, or from
+   * content_allowed_values();
+   */
+  function allowed_values() {
+    $options = nodereference_allowed_values($this->content_field);
+    return (array) $options;
+  }
+
+
+  function option_definition() {
+    $options = parent::option_definition();
+    $options['break_phrase'] = array('default' => FALSE);
+
+    return $options;
+  }
+
+  function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+
+    unset($form['require_value']);
+    unset($form['add_table']);
+
+    // allow for , delimited values
+    $form['break_phrase'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Allow multiple terms per argument.'),
+      '#description' => t('If selected, users can enter multiple arguments in the form of 1,2,3.'),
+      '#default_value' => !empty($this->options['break_phrase']),
+    );
+  }
+
+  /**
+   * Provide a list of default behaviors for this argument if the argument
+   * is not present.
+   *
+   * Provide fewer methods that the standard. Remove summary views
+   */
+  function default_actions($which = NULL) {
+    $defaults = array(
+      'ignore' => array(
+        'title' => t('Display all values'),
+        'method' => 'default_ignore',
+        'breadcrumb' => TRUE, // generate a breadcrumb to here
+      ),
+      'not found' => array(
+        'title' => t('Hide view / Page not found (404)'),
+        'method' => 'default_not_found',
+        'hard fail' => TRUE, // This is a hard fail condition
+      ),
+      'empty' => array(
+        'title' => t('Display empty text'),
+        'method' => 'default_empty',
+        'breadcrumb' => TRUE, // generate a breadcrumb to here
+      ),
+      'default' => array(
+        'title' => t('Provide default argument'),
+        'method' => 'default_default',
+        'form method' => 'default_argument_form',
+        'has default argument' => TRUE,
+        'default only' => TRUE, // this can only be used for missing argument, not validation failure
+      ),
+    );
+
+    if ($which) {
+      if (!empty($defaults[$which])) {
+        return $defaults[$which];
+      }
+    }
+    else {
+      return $defaults;
+    }
+  }
+
+}
Index: handlers/apachesolr_views_handler_filter_author.inc
===================================================================
--- handlers/apachesolr_views_handler_filter_author.inc	(revision 1776)
+++ handlers/apachesolr_views_handler_filter_author.inc	(working copy)
@@ -13,7 +13,7 @@
     
     if (empty($uids) && ($this->options['exposed'] && empty($this->options['expose']['optional']))) {
       if (!$not) {
-        $this->query->add_filter('nid', apachesolr_views_query::escape_term('-1'));
+        $this->query->add_filter('uid', apachesolr_views_query::escape_term('-1'));
       }
     }
     else {
Index: handlers/apachesolr_views_handler_field_nodereference.inc
===================================================================
--- handlers/apachesolr_views_handler_field_nodereference.inc	(revision 0)
+++ handlers/apachesolr_views_handler_field_nodereference.inc	(revision 0)
@@ -0,0 +1,27 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * provides a field handler for the snippet coming from the ApacheSolr search engine
+ */
+class apachesolr_views_handler_field_nodereference extends views_handler_field {
+  function query() {
+    $this->query->add_field($this->real_field);
+  }
+
+  function render($doc) {
+    if (is_array($doc->{$this->real_field})) {
+      $values = $doc->{$this->real_field};
+    }
+    else {
+      $values = array($doc->{$this->real_field});
+    }
+    
+    $titles = array();
+    foreach ($values as $nid) {
+      $titles[] = db_result(db_query('SELECT title FROM {node} WHERE nid = %d', $nid));
+    }
+    return implode(', ', $titles);
+  }
+}
Index: handlers/apachesolr_views_handler_filter_nodereference.inc
===================================================================
--- handlers/apachesolr_views_handler_filter_nodereference.inc	(revision 0)
+++ handlers/apachesolr_views_handler_filter_nodereference.inc	(revision 0)
@@ -0,0 +1,253 @@
+<?php
+// $Id$
+
+/**
+ * Class for filtering by nodereference nid.
+ */
+class apachesolr_views_handler_filter_nodereference extends content_handler_filter_many_to_one {
+
+  public function query() {
+
+    $not = $this->operator == 'not in';
+    $nids = $this->value;
+
+    if (empty($nids)) {
+      if (!$not) {
+        $this->query->add_filter($this->real_field, apachesolr_views_query::escape_term('-1'));
+      }
+    }
+    else {
+      foreach ($nids as $nid) {
+        $filter_string .= " OR $nid";
+      }
+      
+      // Construct a small subquery.
+      $filter_string = substr($filter_string, 4);
+      $filter_string = "($filter_string)";
+//print_r('query::' . $this->real_field . '::' . $filter_string . '::' . $not);
+      // Add it to the query.
+      $this->query->add_filter($this->real_field, $filter_string, $not);
+    }
+  }
+
+  function has_extra_options() {
+    return TRUE;
+  }
+
+  function option_definition() {
+    $options = parent::option_definition();
+    $options['type'] = array('default' => 'textfield');
+    return $options;
+  }
+
+  function extra_options_form(&$form, &$form_state) {
+    $form['markup_start'] = array(
+      '#value' => '<div class="views-left-40">',
+    );
+    $form['type'] = array(
+      '#type' => 'radios',
+      '#title' => t('Selection type'),
+      '#options' => array('select' => t('Dropdown'), 'textfield' => t('Autocomplete')),
+      '#default_value' => $this->options['type'],
+    );
+    $form['markup_end'] = array(
+      '#value' => '</div>',
+    );
+  }
+
+  /**
+   * Get allowed values from hook_allowed_values(), if any, or from
+   * content_allowed_values();
+   */
+  function allowed_values() {
+    $options = nodereference_allowed_values(content_fields($this->definition['cck_field']['field_name']));;
+    return (array) $options;
+  }
+
+  function value_form(&$form, &$form_state) {
+    $form['value'] = array();
+
+    if ($this->options['type'] == 'select') {
+      $this->get_value_options();
+      $options = $this->value_options;
+      $default_value = (array) $this->value;
+
+      $which = 'all';
+      if (!empty($form['operator'])) {
+        $source = ($form['operator']['#type'] == 'radios') ? 'radio:options[operator]' : 'edit-options-operator';
+      }
+      if (!empty($form_state['exposed'])) {
+        $identifier = $this->options['expose']['identifier'];
+
+        if (empty($this->options['expose']['use_operator']) || empty($this->options['expose']['operator'])) {
+          // Exposed and locked.
+          $which = in_array($this->operator, $this->operator_values(1)) ? 'value' : 'none';
+        }
+        else {
+          $source = 'edit-' . form_clean_id($this->options['expose']['operator']);
+        }
+
+        if (!empty($this->options['expose']['reduce'])) {
+          $options = $this->reduce_value_options();
+
+          if (empty($this->options['expose']['single']) && !empty($this->options['expose']['optional'])) {
+            $default_value = array();
+          }
+        }
+
+        if (!empty($this->options['expose']['single'])) {
+          if (!empty($this->options['expose']['optional']) && (empty($default_value) || !empty($this->options['expose']['reduce']))) {
+            $default_value = 'All';
+          }
+          else if (empty($default_value)) {
+            $keys = array_keys($options);
+            $default_value = array_shift($keys);
+          }
+          else {
+            $copy = $default_value;
+            $default_value = array_shift($copy);
+          }
+        }
+      }
+
+      if ($which == 'all' || $which == 'value') {
+        if ($this->value_form_type == 'checkboxes') {
+          foreach ($options as $key => $option) {
+            $options[$key] = check_plain($option);
+          }
+        }
+        $form['value'] = array(
+          '#type' => $this->value_form_type,
+          '#title' => $this->value_title,
+          '#options' => $options,
+          '#default_value' => $default_value,
+          // These are only valid for 'select' type, but do no harm to checkboxes.
+          '#multiple' => TRUE,
+          '#size' => count($options) > 8 ? 8 : count($options),
+          '#pre_render' => array('apachesolr_views_handler_filter_cleanup'),
+        );
+        if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier])) {
+          $form_state['input'][$identifier] = $default_value;
+        }
+
+        if ($which == 'all') {
+          $process = array();
+          if ($this->value_form_type == 'checkboxes' || $this->value_form_type == 'radios') {
+            $process[] = "expand_$this->value_form_type";
+            $form['value']['#prefix'] = '<div id="edit-options-value-wrapper">';
+            $form['value']['#suffix'] = '</div>';
+          }
+          $process[] = 'views_process_dependency';
+          $form['value'] += array(
+            '#process' => $process,
+            '#dependency' => array($source => $this->operator_values(1)),
+          );
+        }
+      }
+
+      if (empty($form_state['exposed'])) {
+        $this->helper->options_form($form, $form_state);
+      }
+    }
+    elseif ($this->options['type'] == 'textfield') {
+      $default = '';
+      if (is_numeric($this->value)) {
+        $default = check_plain(db_result(db_query('SELECT title FROM {node} WHERE nid = %d', $this->value)));
+        if ($this->options['expose']['show_nid']) {
+          $default .= ' [nid:' . $this->value . ']';
+        }
+      }
+      else {
+        $default = $this->value;
+      }
+      
+      $form['value'] = array(
+        '#title' => $this->value_title,
+        '#type' => 'textfield',
+        '#default_value' => $default,
+      );
+      if ($this->options['expose']['show_nid']) {
+        $form['value']['#autocomplete_path'] = 'nodereference/autocomplete/'. $this->definition['cck_field']['field_name'];
+      }
+      else {
+        $form['value']['#autocomplete_path'] = 'apachesolr-views/nodereference/autocomplete/'. $this->definition['cck_field']['field_name'];
+      }
+    }
+  }
+
+  function value_validate(&$form, &$form_state) {
+    // We only validate if they've chosen the text field style.
+    if ($this->options['type'] != 'textfield') {
+      return;
+    }
+
+    $nid = $this->nodereference_validate($form, $form_state['values']['options']['value']);
+
+    $form_state['values']['options']['value'] = $nid;
+  }
+
+  function exposed_validate(&$form, &$form_state) {
+    if (empty($this->options['exposed'])) {
+      return;
+    }
+
+    $identifier = $this->options['expose']['identifier'];
+
+    // We only validate if they've chosen the text field style.
+    if ($this->options['type'] != 'textfield') {
+
+      if ($form_state['values'][$identifier] != 'All')  {
+        $this->validated_exposed_input = (array) $form_state['values'][$identifier];
+      }
+      return;
+    }
+
+    if (empty($this->options['expose']['identifier'])) {
+      return;
+    }
+    $nid = $this->nodereference_validate($form, $form_state['values'][$identifier]);
+    $this->validated_exposed_input = $nid;
+    $form_state['values'][$identifier] = $nid;
+  }
+
+  function nodereference_validate(&$form, $value) {
+    $field = content_fields($this->definition['cck_field']['field_name']);
+    if (!empty($value)) {
+      preg_match('/^(?:\s*|(.*) )?\[\s*nid\s*:\s*(\d+)\s*\]$/', $value, $matches);
+      if (!empty($matches)) {
+        // Explicit [nid:n].
+        list(, $title, $nid) = $matches;
+        if (!empty($title) && ($n = node_load($nid)) && $title != $n->title) {
+          form_error($form['value'], t('%name: title mismatch. Please check your selection.', array('%name' => t($field['widget']['label']))));
+        }
+      }
+      else {
+        // No explicit nid.
+        $reference = _nodereference_potential_references($field, $value, 'equals', NULL, 1);
+        if (empty($reference)) {
+          form_error($form['value'], t('%name: found no valid post with that title.', array('%name' => t($field['widget']['label']))));
+        }
+        else {
+          $nid = key($reference);
+        }
+      }
+    }
+
+    return $nid;
+  }
+
+  function expose_options() {
+    parent::expose_options();
+    $this->options['expose']['show_nid'] = TRUE;
+  }
+
+  function expose_form_right(&$form, &$form_state) {
+    parent::expose_form_right($form, $form_state);
+    $form['expose']['show_nid'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Show nid in text field'),
+      '#description' => t('If checked, the autocomplete field will contain the node id. This can yield more accurate results.'),
+      '#default_value' => !empty($this->options['expose']['show_nid']),
+    );
+  }
+}
Index: handlers/apachesolr_views_handler_filter_tid.inc
===================================================================
--- handlers/apachesolr_views_handler_filter_tid.inc	(revision 1776)
+++ handlers/apachesolr_views_handler_filter_tid.inc	(working copy)
@@ -18,7 +18,13 @@
     }
     
   }
-    
+
+  function value_form(&$form, &$form_state) {
+    parent::value_form($form, $form_state);
+    $form['value']['#pre_render'] = array('apachesolr_views_handler_filter_cleanup');
+    $form['value']['#vid'] = 'im_vid_' . $this->options['vid'];
+  }
+
   function exposed_validate(&$form, &$form_state) {
     
     parent::exposed_validate($form, $form_state);
Index: apachesolr_views.module
===================================================================
--- apachesolr_views.module	(revision 1776)
+++ apachesolr_views.module	(working copy)
@@ -30,6 +30,100 @@
 }
 
 /**
+ * Implementation of hook_menu().
+ */
+function apachesolr_views_menu() {
+  $items = array();
+  $items['apachesolr-views/nodereference/autocomplete'] = array(
+    'title' => 'Nodereference autocomplete',
+    'page callback' => 'apachesolr_views_nodereference_autocomplete',
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK
+  );
+  $items['apachesolr-views/userreference/autocomplete'] = array(
+    'title' => 'Userreference autocomplete',
+    'page callback' => 'apachesolr_views_userreference_autocomplete',
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK
+  );
+  return $items;
+}
+
+/**
+ * Custom nodereference autocomplete
+ */
+function apachesolr_views_nodereference_autocomplete($field_name, $string = '') {
+  $fields = content_fields();
+  $field = $fields[$field_name];
+  $match = isset($field['widget']['autocomplete_match']) ? $field['widget']['autocomplete_match'] : 'contains';
+  $matches = array();
+
+  $references = _nodereference_potential_references($field, $string, $match, array(), 10);
+  foreach ($references as $id => $row) {
+    // Add a class wrapper for a few required CSS overrides.
+    $matches[$row['title']] = '<div class="reference-autocomplete">'. $row['rendered'] . '</div>';
+  }
+  drupal_json($matches);
+}
+
+/**
+ * Custom nodereference autocomplete
+ */
+function apachesolr_views_userreference_autocomplete($field_name, $string = '') {
+  $fields = content_fields();
+  $field = $fields[$field_name];
+  $match = isset($field['widget']['autocomplete_match']) ? $field['widget']['autocomplete_match'] : 'contains';
+  $matches = array();
+
+  $references = _userreference_potential_references($field, $string, $match, array(), 10);
+  foreach ($references as $id => $row) {
+    // Add a class wrapper for a few required CSS overrides.
+    $matches[$row['title']] = '<div class="reference-autocomplete">'. $row['rendered'] . '</div>';
+  }
+  drupal_json($matches);
+}
+
+function apachesolr_views_handler_filter_cleanup($element) {
+  static $done = array();
+  
+  if (!isset($done[$element['#name']])) {
+    $done[$element['#name']] = TRUE;
+    $solr = apachesolr_static_response_cache();
+    if (isset($solr)) {
+      $options = $element['#options'];
+      $selectedoptions = $element['#value'];
+      if (isset($element['#vid'])) {
+        $elname = $element['#vid'];
+      }
+      else {
+        $elname = $element['#name'];
+      }
+      $facets = array();
+      $facet = $solr->facet_counts->facet_fields->{$elname};
+      if (isset($facet)) {
+        foreach ($facet as $k => $f) {
+          $facets[$k] = $k;
+        }
+      }
+      if (isset($facet) && isset($facets)) {
+        $intersect = array_intersect_key($options, $facets);
+        if (!empty($intersect)) {
+          $element['#options'] = $intersect;
+        }
+        else {
+          $element['#options'] = array_intersect_key($options, $selectedoptions);
+        }
+      }
+      else {
+        $element['#options'] = array_intersect_key($options, $selectedoptions);
+      }
+    }
+  }
+
+  return $element;
+}
+
+/**
  * Implementation of hook_apachesolr_entities().
  * This is done for apachesolr_search module.
  */
Index: apachesolr_views.views.inc
===================================================================
--- apachesolr_views.views.inc	(revision 1776)
+++ apachesolr_views.views.inc	(working copy)
@@ -16,6 +16,9 @@
       'apachesolr_views_handler_argument_optionwidget' => array(
         'parent' => 'apachesolr_views_handler_argument',
       ),
+     'apachesolr_views_handler_argument_nodereference' => array(
+        'parent' => 'content_handler_argument_many_to_one',
+      ),
       'apachesolr_views_handler_argument_node_type' => array(
         'parent' => 'apachesolr_views_handler_argument',
       ),
@@ -59,6 +62,12 @@
       'apachesolr_views_handler_field_snippet' => array(
         'parent' => 'views_handler_field',
       ),
+      'apachesolr_views_handler_field_nodereference' => array(
+        'parent' => 'views_handler_field',
+      ),
+      'apachesolr_views_handler_field_userreference' => array(
+        'parent' => 'views_handler_field',
+      ),
       'apachesolr_views_handler_filter_tid' => array(
         'parent' => 'views_handler_filter_term_node_tid',
       ),
@@ -83,6 +92,12 @@
       'apachesolr_views_handler_filter_boolean' => array(
         'parent' => 'views_handler_filter_boolean_operator',
       ),
+      'apachesolr_views_handler_filter_nodereference' => array(
+        'parent' => 'content_handler_filter_many_to_one',
+      ),
+      'apachesolr_views_handler_filter_userreference' => array(
+        'parent' => 'content_handler_filter_many_to_one',
+      ),
       'apachesolr_views_handler_sort' => array(
         'parent' => 'views_handler_sort',
       ),
@@ -314,7 +329,7 @@
       // TODO: can we make use of CCK's mapping already and just override
       // the query part???
       $options = content_allowed_values(content_fields($field['field_name']));
-      if (!empty($options)) {
+      if (!empty($options) && $field['type'] != 'nodereference' && $field['type'] != 'userreference') {
         $label = (isset($field['widget']['label'])) ? t($field['widget']['label']) : '';
         $data['apachesolr_' . $base_table][apachesolr_index_key($field)] = array(
           'title' => $label,
@@ -329,6 +344,38 @@
           ),
         ); // end: array
       } // end: if
+      elseif ($field['type'] == 'nodereference') {
+       $data['apachesolr_' . $base_table][apachesolr_index_key($field)] = array(
+         'title' => t($field['field_name']),
+         'help' => t('CCK Mapping for @fieldname', array('@fieldname' => $field['field_name'])),
+         'field' => array(
+           'handler' => 'apachesolr_views_handler_field_nodereference',
+         ),
+         'filter' => array(
+           'handler' => 'apachesolr_views_handler_filter_nodereference',
+           'cck_field' => $field,
+           'label' => t($field['field_name']),
+         ),
+         'argument' => array(
+           'handler' => 'apachesolr_views_handler_argument_nodereference',
+           'cck_field' => $field,
+         ),
+       );
+      }
+      elseif ($field['type'] == 'userreference') {
+       $data['apachesolr_' . $base_table][apachesolr_index_key($field)] = array(
+         'title' => t($field['field_name']),
+         'help' => t('CCK Mapping for @fieldname', array('@fieldname' => $field['field_name'])),
+         'field' => array(
+           'handler' => 'apachesolr_views_handler_field_userreference',
+         ),
+         'filter' => array(
+           'handler' => 'apachesolr_views_handler_filter_userreference',
+           'cck_field' => $field,
+           'label' => t($field['field_name']),
+         ),
+       );
+      }
     } // end: foreach
   } // end: foreach
   
