Perhaps I misunderstand the thinking behind the operator, but when using the "OR" operator, I get the following errors with my view:

    * warning: implode() [function.implode]: Bad arguments. in /sites/all/modules/views_fastsearch/views_fastsearch.module on line 140.
    * user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1 query: SELECT count(node.nid) FROM node node LEFT JOIN users_roles users_roles ON node.uid = users_roles.uid INNER JOIN users users ON node.uid = users.uid LEFT JOIN content_type_bio node_data_field_first_name ON node.vid = node_data_field_first_name.vid LEFT JOIN content_type_bio node_data_field_last_name ON node.vid = node_data_field_last_name.vid WHERE (users_roles.rid = '3') AND (node.type IN ('bio')) AND (()) in /includes/database.mysql.inc on line 172.
    * user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) ORDER BY node_data_field_last_name_field_last_name_value ASC LIMIT 0, 50' at line 1 query: SELECT node.nid, users.uid AS users_uid, node_data_field_first_name.field_first_name_value AS node_data_field_first_name_field_first_name_value, node_data_field_last_name.field_last_name_value AS node_data_field_last_name_field_last_name_value FROM node node LEFT JOIN users_roles users_roles ON node.uid = users_roles.uid INNER JOIN users users ON node.uid = users.uid LEFT JOIN content_type_bio node_data_field_first_name ON node.vid = node_data_field_first_name.vid LEFT JOIN content_type_bio node_data_field_last_name ON node.vid = node_data_field_last_name.vid WHERE (users_roles.rid = '3') AND (node.type IN ('bio')) AND (()) ORDER BY node_data_field_last_name_field_last_name_value ASC LIMIT 0, 50 in /includes/database.mysql.inc on line 172.

Currently I'm working around this, but I'd like to be able to do an OR based keyword search.

Here's the view export, for yr reference:

  $view = new stdClass();
  $view->name = 'directory';
  $view->description = 'Staff Directory';
  $view->access = array (
);
  $view->view_args_php = '';
  $view->page = TRUE;
  $view->page_title = 'IFTF Staff Directory';
  $view->page_header = '';
  $view->page_header_format = '1';
  $view->page_footer = '';
  $view->page_footer_format = '1';
  $view->page_empty = '';
  $view->page_empty_format = '1';
  $view->page_type = 'table';
  $view->url = 'people/directory';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '50';
  $view->menu = TRUE;
  $view->menu_title = 'directory';
  $view->menu_tab = FALSE;
  $view->menu_tab_weight = '0';
  $view->menu_tab_default = FALSE;
  $view->menu_tab_default_parent = NULL;
  $view->menu_tab_default_parent_type = 'tab';
  $view->menu_parent_tab_weight = '0';
  $view->menu_parent_title = '';
  $view->sort = array (
  );
  $view->argument = array (
  );
  $view->field = array (
    array (
      'tablename' => 'users',
      'field' => 'uid',
      'label' => '',
    ),
    array (
      'tablename' => 'node_data_field_first_name',
      'field' => 'field_first_name_value',
      'label' => 'First Name',
      'handler' => 'content_views_field_handler_group',
      'sortable' => '1',
      'options' => 'default',
    ),
    array (
      'tablename' => 'node_data_field_last_name',
      'field' => 'field_last_name_value',
      'label' => 'Last Name',
      'handler' => 'content_views_field_handler_group',
      'sortable' => '1',
      'defaultsort' => 'ASC',
      'options' => 'default',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'users_roles',
      'field' => 'rid',
      'operator' => 'AND',
      'options' => '',
      'value' => array (
  0 => '3',
),
    ),
    array (
      'tablename' => 'node',
      'field' => 'type',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => 'bio',
),
    ),
    array (
      'tablename' => 'search_index',
      'field' => 'word',
      'operator' => 'AND+',
      'options' => '',
      'value' => '',
    ),
  );
  $view->exposed_filter = array (
    array (
      'tablename' => 'search_index',
      'field' => 'word',
      'label' => '',
      'optional' => '1',
      'is_default' => '0',
      'operator' => '1',
      'single' => '0',
    ),
  );
  $view->requires = array(users, node_data_field_first_name, node_data_field_last_name, users_roles, node, search_index);
  $views[$view->name] = $view;
CommentFileSizeAuthor
#1 or-operator-issue.patch946 bytesmlsamuelson

Comments

mlsamuelson’s picture

Status: Active » Needs work
StatusFileSize
new946 bytes

I'm having the same error. I believe I identified a logic error on line 81 which would result in an "always true" when the "or" operator is being used - meaning that the logic check following it would never fire for subsequent iterations of the containing foreach loop, which appeared to be the intent.

I've made a patch that resolves the errors on the view page and results in successful queries with the view, I still see the following on the edit page for the view only when the OR operator is selected:

warning: preg_match() expects parameter 2 to be string, array given in C:\Program Files\Apache Group\Apache2\htdocs\icfl\includes\bootstrap.inc on line 670.

I'm out of time at the moment and have to get to an appointment, so I thought I'd share what I have thus far...

douggreen’s picture

Status: Needs work » Closed (won't fix)

Please use the 5.x-2.x version.

douggreen’s picture

btw, I don't think this is a logic error.

mlsamuelson’s picture

Thanks douggreen!

The 5.x-2.x version resolves the issue.

I'm guessing it's an unrelated issue but on the view page and the edit page for the view I do still get

warning: preg_match() expects parameter 2 to be string, array given in C:\Program Files\Apache Group\Apache2\htdocs\icfl\includes\bootstrap.inc on line 670.

when the filter is not marked "optional" and before any searches have been conducted.

mlsamuelson

lee20’s picture

Subscribing....I have the same issue with the same configurtion, OR search with the filter not marked optional.

lee20’s picture

After stepping through a backtrace of the error, it seems when the exposed filter is themed through "theme_textfield", the $element['#value'] is an empty array. I am not sure what is setting this to an array, but it appears to be a possible bug in the Views module, or an issue with how the fast search filter is interacting with views. At any case, this is a work around to preventing the error:

function phptemplate_textfield($element) {
	if (is_array($element['#value'])) $element['#value'] = '';
	return theme_textfield($element);
}
trantr’s picture

Dear Lee20

I got problem with using OR search without checking the Optional in Exposed Filter, can you tell me where i place this code for the work around?