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...

Comments

janusman’s picture

Status: Active » Needs review
StatusFileSize
new1.3 KB

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)),
+          );
+        }
       }
     }
   }
josh waihi’s picture

Category: feature » bug
Priority: Normal » Critical

This isn't a feature request its a bug that needs fixing.

pwolanin’s picture

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?

pwolanin’s picture

Priority: Critical » Minor
janusman’s picture

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..)

pwolanin’s picture

The spellcheck index is re-built on optimize I think - so that may only happen once per day.

josh waihi’s picture

whats wrong with fixing this in PHP if it happens?

robertdouglass’s picture

Version: 6.x-2.x-dev » 6.x-1.x-dev
Status: Needs review » Patch (to be ported)

Looks like a decent improvement. We can investigate the intricacies of Solr's spelling suggestions later. Applied to DRUPAL-6--2

robertdouglass’s picture

Version: 6.x-1.x-dev » 5.x-2.x-dev

And to DRUPAL-6--1.

claudiu.cristea’s picture

Status: Patch (to be ported) » Fixed
StatusFileSize
new1.4 KB

Fixed in #317524.

Patch for 5.x-2.x-dev attached.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.