From c99dd5c2064df28932f13e5182676f281a699d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Wed, 5 Dec 2007 12:38:03 +0000 Subject: #186242 by douggreen: ignore AND in search, as it is the default behavior and inform the user when a lower case 'or' is used that 'OR' should be used as an operator --- modules/search/search.module | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/search/search.module b/modules/search/search.module index a10214325..fafb6b4f1 100644 --- a/modules/search/search.module +++ b/modules/search/search.module @@ -710,7 +710,7 @@ function search_parse_query($text) { // Classify tokens $or = FALSE; - $or_warning = FALSE; + $warning = ''; $simple = TRUE; foreach ($matches as $match) { $phrase = FALSE; @@ -740,10 +740,16 @@ function search_parse_query($text) { $or = TRUE; continue; } + // AND operator: implied, so just ignore it + elseif ($match[2] == 'AND' || $match[2] == 'and') { + $warning = $match[2]; + continue; + } + // Plain keyword else { if ($match[2] == 'or') { - $or_warning = TRUE; + $warning = $match[2]; } if ($or) { // Add to last element (which is an array) @@ -814,7 +820,7 @@ function search_parse_query($text) { // Build word-index conditions for the first pass $query2 = substr(str_repeat("i.word = '%s' OR ", count($arguments2)), 0, -4); - return array($query, $arguments, $query2, $arguments2, $matches, $simple, $or_warning); + return array($query, $arguments, $query2, $arguments2, $matches, $simple, $warning); } /** @@ -901,7 +907,9 @@ function do_search($keywords, $type, $join1 = '', $where1 = '1', $arguments1 = a form_set_error('keys', t('You must include at least one positive keyword with @count characters or more.', array('@count' => variable_get('minimum_word_size', 3)))); } if ($query[6]) { - form_set_error('keys', t('Try uppercase "OR" to search for either of two terms.')); + if ($query[6] == 'or') { + drupal_set_message(t('Search for either of the two terms with uppercase OR. For example, cats OR dogs.')); + } } if ($query === NULL || $query[0] == '' || $query[2] == '') { return array(); -- cgit v1.2.3