If the user enters a single stop word into search-field (eg. the expression "wenig") and the minimum word size is set to any value >0, the user received the improper warning, that the entered search expression has to be longer than the min word size. This confuses quite much.

The following changes of de_stemmer.module eliminate these problem:

additional definition:

define('DE_STEMMER_DEFAULT_SEARCH_TEXT', 'aeueoeaeoeue');

modified function:

function de_stemmer_search_preprocess($text) {

...
// Put it all back together...but check, if min word size was under-run by elimination of stop words
$return = implode('', $words);
$min_word_size = intval(variable_get('minimum_word_size', 3));
if (drupal_strlen($return) < $min_word_size && drupal_strlen($text) >= $min_word_size ) {
return DE_STEMMER_DEFAULT_SEARCH_TEXT;
}
else {
return $return;
}
}

The DE_STEMMER_DEFAULT_SEARCH_TEXT should be a string, which is very improbable to exist as index search key.

Comments

schildi’s picture

OK, I knew about this behavior but didn't pay attention to it.
May be it is better to hide this from the user by implementing some kind of a dummy search word. I will check this. And I will also check for possible alternate solutions. May be there is a way to set this dummy search expression to a compilation of characters which can't be part of a search word - special characters or a tag.

Nice to see that someone is going more in details and has a look at the code.

Regards

schildi’s picture

Assigned: Unassigned » schildi
Priority: Normal » Minor
schildi’s picture

Currently the search process of my sites are based on "search lucene". I hope it's behavior does not differ too much from ordinary core search.
An alternate way to the one you recommended seems to set a simple underscore in the case when only stop words are searched (function de_stemmer_search_preprocess):

  // Process each word
  $w_cnt = 0;   // number of words (should be > 0)
  $odd = true;
  foreach ($words as $k => $word) {
    if ($odd) {
      if (!_de_stemmer_stoppwort($word)) {
        $words[$k] = _de_stemmer_wortstamm($word);
        ++$w_cnt;
      } else {
        $words[$k] = '';
      }
    }
    $odd = !$odd;
  }

  if (!$w_cnt) {        // no words left
        $words[1] = '_';  // first word with odd index
  }
  // Put it all back together
  return implode('', $words);

This results in a normal "Die Suche lieferte keine Ergebnisse." when searching for stop words only.
I will give this a try and commit the change to head.

schildi’s picture

Status: Active » Closed (fixed)