At Google, a user can input text and select 'Google Search' or 'I'm Feeling Lucky'

Google Search offers a list of search results, akin to the Drupal Search button.

Google I'm Feeling Lucky sends users directly to a result.

Has something done something like this with Drupal?

Perhaps matching the input with node titles and sending the user to the most relevant title?

This is also similar to the Wikipedia Go button (vs. the Wikipedia Search button).

Comments

carl ditzler’s picture

Any chance someone has implemented something like this?

Edward C. Zimmermann@drupal.org’s picture

"At Google, a user can input text and select 'Google Search' or 'I'm Feeling Lucky'"

Its a silly idea that, in the case of Google, depends upon their concept that nobody is really looking for anything specific but want something assuming the highest page ranked is just good enough. One needs to recall that the results of Google search are ordered (in fact of the 100s of 1000s of machines they have running, different results for the same query are commonplace so they are not even consistently sorted) BUT by a melange of link-count, popularity and google bias (human intervention by their editors). Worse still is the observation that Google with this model, to put it into political perspective, loves dictators and ideological oligarchies. The "lucky" feature is just a (historical) logical consequence. Who needs democratic elections when fearless leader knows what's best?

In a blog/CMS such as Drupal you won't want this do you?
In an individual Drupal or in a defined network of Drupals one wants, instead, I would argue, to find specific and relevant articles.

Steven’s picture

I implemented this as an intelligent 404 page on my site. If the page does not exist, a search is performed and the user is sent to the first result.

But on my site, this works because all content is relevant and posted by me. So I use it as an excuse to not have to remember URLs. E.g.:

http://acko.net/sprankle

On a site like Drupal.org this wouldn't be very useful because there is a lot of noise in between the signal.

--
If you have a problem, please search before posting a question.

alexandreracine’s picture

is used by less then 0,5% of all google users.

nimi’s picture

Hi Quam,
Have you found a solution for this?
I"m looking for this feature too :)

Thanks.

carl ditzler’s picture

Unfortunately I did not find a lucky or go function with search. Anyone?

jessie_az’s picture

In case someone comes across this thread, I have discovered a solution, thanks to this website: http://wtanaka.com/node/7761

The solution as stated there didn't work for me, but I was able to adapt the code provided for use in the search-results.tpl.php file, which you'll find in the search module. Copy that file and replace the code in there with the following:

<?php 
if ('node' == $type && 1 == count($results))
   {
      $item = current($results);
      drupal_goto($item['link']);
   }
   else { ?>
      
<dl class="search-results <?php print $type; ?>-results">
  <?php print $search_results; ?>
</dl>
<?php print $pager; ?>
<?php } ?>

This creates a conditional that redirects the page to the one result if there is only one.

Then, put this copy in your theme directory. And clear your cache:
admin > settings > performance

This overrides the search results page in the module with the custom one you made.

That worked for me. I hope this helps someone!