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

janusman - August 26, 2009 - 21:18
Status:active» needs review

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)),
+          );
+        }
       }
     }
   }

AttachmentSize
apachesolr-558836-1.patch 1.3 KB

#2

Josh Waihi - October 20, 2009 - 22:14
Category:feature request» bug report
Priority:normal» critical

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

#3

pwolanin - October 21, 2009 - 15:33

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

pwolanin - October 21, 2009 - 15:33
Priority:critical» minor

#5

janusman - October 26, 2009 - 15:43

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

pwolanin - October 26, 2009 - 16:32

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

#7

Josh Waihi - October 28, 2009 - 00:57

whats wrong with fixing this in PHP if it happens?

#8

robertDouglass - November 6, 2009 - 10:57
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

#9

robertDouglass - November 6, 2009 - 10:59
Version:6.x-1.x-dev» 5.x-2.x-dev

And to DRUPAL-6--1.

 
 

Drupal is a registered trademark of Dries Buytaert.