diff --git a/handlers/apachesolr_views_handler_filter.inc b/handlers/apachesolr_views_handler_filter.inc index 083292f..22069d3 100644 --- a/handlers/apachesolr_views_handler_filter.inc +++ b/handlers/apachesolr_views_handler_filter.inc @@ -6,12 +6,15 @@ class apachesolr_views_handler_filter extends views_handler_filter { if (is_array($this->value)) { $this->value = implode(' OR ', $this->value); } + if($this->value != '' && $this->options['solr']['partial_matching']){ + $this->value = $this->value . ' OR ' . $this->value . '*'; + } $this->query->add_where($this->options['group'], "$this->real_field", $this->value, $this->operator); } } /** - * Provide a simple textfield for equality + * Provide a simple textfield for equality, and a checkbox for partial matches */ function value_form(&$form, &$form_state) { $form['value'] = array( @@ -20,4 +23,34 @@ class apachesolr_views_handler_filter extends views_handler_filter { '#default_value' => $this->value, ); } + + /** + * Adds the solr partial matching checkbox to the options form + */ + function options_form(&$form, &$form_state) { + parent::options_form($form, $form_state); + + $form['solr'] = array( + 'partial_matching' => array( + '#type' => 'checkbox', + '#title' => 'Allow partial matching', + '#default_value' => $this->options['solr']['partial_matching'], + ), + ); + } + + /** + * Define the partial match option + */ + function option_definition() { + $options = parent::option_definition(); + + $options['solr'] = array( + 'contains' => array( + 'partial_matching' => array('default' => 0), + ), + ); + + return $options; + } } \ No newline at end of file