#205920 by douggreen: short term searches were returning wrong results
							parent
							
								
									b571a82e4e
								
							
						
					
					
						commit
						444c5e16be
					
				| 
						 | 
					@ -778,8 +778,8 @@ function search_parse_query($text) {
 | 
				
			||||||
      $queryor = array();
 | 
					      $queryor = array();
 | 
				
			||||||
      $any = FALSE;
 | 
					      $any = FALSE;
 | 
				
			||||||
      foreach ($key as $or) {
 | 
					      foreach ($key as $or) {
 | 
				
			||||||
        list($q, $count) = _search_parse_query($or, $arguments2);
 | 
					        list($q, $num_new_scores) = _search_parse_query($or, $arguments2);
 | 
				
			||||||
        $any |= $count;
 | 
					        $any |= $num_new_scores;
 | 
				
			||||||
        if ($q) {
 | 
					        if ($q) {
 | 
				
			||||||
          $queryor[] = $q;
 | 
					          $queryor[] = $q;
 | 
				
			||||||
          $arguments[] = $or;
 | 
					          $arguments[] = $or;
 | 
				
			||||||
| 
						 | 
					@ -794,12 +794,15 @@ function search_parse_query($text) {
 | 
				
			||||||
    // Single ANDed term
 | 
					    // Single ANDed term
 | 
				
			||||||
    else {
 | 
					    else {
 | 
				
			||||||
      $simple_and = TRUE;
 | 
					      $simple_and = TRUE;
 | 
				
			||||||
      list($q, $count) = _search_parse_query($key, $arguments2);
 | 
					      list($q, $num_new_scores, $num_valid_words) = _search_parse_query($key, $arguments2);
 | 
				
			||||||
      if ($q) {
 | 
					      if ($q) {
 | 
				
			||||||
        $query[] = $q;
 | 
					        $query[] = $q;
 | 
				
			||||||
        $arguments[] = $key;
 | 
					        $arguments[] = $key;
 | 
				
			||||||
 | 
					        if (!$num_valid_words) {
 | 
				
			||||||
 | 
					          $simple = FALSE;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        // Each AND keyword needs to match at least once
 | 
					        // Each AND keyword needs to match at least once
 | 
				
			||||||
        $matches += $count;
 | 
					        $matches += $num_new_scores;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					@ -827,7 +830,8 @@ function search_parse_query($text) {
 | 
				
			||||||
 * Helper function for search_parse_query();
 | 
					 * Helper function for search_parse_query();
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
function _search_parse_query(&$word, &$scores, $not = FALSE) {
 | 
					function _search_parse_query(&$word, &$scores, $not = FALSE) {
 | 
				
			||||||
  $count = 0;
 | 
					  $num_new_scores = 0;
 | 
				
			||||||
 | 
					  $num_valid_words = 0;
 | 
				
			||||||
  // Determine the scorewords of this word/phrase
 | 
					  // Determine the scorewords of this word/phrase
 | 
				
			||||||
  if (!$not) {
 | 
					  if (!$not) {
 | 
				
			||||||
    $split = explode(' ', $word);
 | 
					    $split = explode(' ', $word);
 | 
				
			||||||
| 
						 | 
					@ -837,13 +841,14 @@ function _search_parse_query(&$word, &$scores, $not = FALSE) {
 | 
				
			||||||
        $s = $num ? ((int)ltrim($s, '-0')) : $s;
 | 
					        $s = $num ? ((int)ltrim($s, '-0')) : $s;
 | 
				
			||||||
        if (!isset($scores[$s])) {
 | 
					        if (!isset($scores[$s])) {
 | 
				
			||||||
          $scores[$s] = $s;
 | 
					          $scores[$s] = $s;
 | 
				
			||||||
          $count++;
 | 
					          $num_new_scores++;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        $num_valid_words++;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  // Return matching snippet and number of added words
 | 
					  // Return matching snippet and number of added words
 | 
				
			||||||
  return array("d.data ". ($not ? 'NOT ' : '') ."LIKE '%% %s %%'", $count);
 | 
					  return array("d.data ". ($not ? 'NOT ' : '') ."LIKE '%% %s %%'", $num_new_scores, $num_valid_words);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue