Don't show "did you mean" when suggested terms are identical
morningtime - August 25, 2009 - 11:18
| Project: | Apache Solr Search Integration |
| Version: | 5.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | patch (to be ported) |
Description
Don't show "did you mean" when suggested terms are identical with the search terms. E.g. search for "activis", did you mean: activis? Doh...

#1
Simple =) Attaching patch.
@@ -919,13 +919,16 @@
}
$new_keywords = strtr($query->get_query_basic(), $replacements);
- $form['basic']['suggestion'] = array(
- '#prefix' => '<div class="spelling-suggestions">',
- '#suffix' => '</div>',
- '#type' => 'item',
- '#title' => t('Did you mean'),
- '#value' => l($new_keywords, $query->get_path($new_keywords)),
- );
+ // Show only if suggestion is different than current query.
+ if ($query->get_query_basic() != $new_keywords) {
+ $form['basic']['suggestion'] = array(
+ '#prefix' => '<div class="spelling-suggestions">',
+ '#suffix' => '</div>',
+ '#type' => 'item',
+ '#title' => t('Did you mean'),
+ '#value' => l($new_keywords, $query->get_path($new_keywords)),
+ );
+ }
}
}
}
#2
This isn't a feature request its a bug that needs fixing.
#3
Why would it ever suggest the same as the current query? Is there something going on in terms of solr's analysis? Perhaps this means you have a stale spellcheck index?
#4
#5
Hmm, well if it *can* happen, shouldn't we validate it? =) I've had it happen even on what I thought were fully-indexed sites, cron running every hour...
Also, do you know if it's normally a symptom of an indexing (or other) problem? (If so perhaps we should even log an error or show a warning to the admins somewhere..)
#6
The spellcheck index is re-built on optimize I think - so that may only happen once per day.
#7
whats wrong with fixing this in PHP if it happens?
#8
Looks like a decent improvement. We can investigate the intricacies of Solr's spelling suggestions later. Applied to DRUPAL-6--2
#9
And to DRUPAL-6--1.