diff --git a/src/Controller/AutocompleteController.php b/src/Controller/AutocompleteController.php
index 09bda4e72e2595606b94e8430efa8d6ede378746..8cb931dc4f4b8e5fdd0e3e0a689298b6abe92f51 100644
--- a/src/Controller/AutocompleteController.php
+++ b/src/Controller/AutocompleteController.php
@@ -29,15 +29,21 @@ class AutocompleteController extends ControllerBase {
    *   Autocomplete results.
    */
   public function searchAutocomplete(BranchInterface $branch, Request $request) {
+    $results = [];
     $input = $request->query->get('q');
     if (!$input) {
       return new JsonResponse([]);
     }
 
     $input = Xss::filter($input);
-    $ids = DocBlock::searchByTitle($input, $branch, 50);
+    // Try exact search results first.
+    $ids = DocBlock::searchByTitle($input, $branch, 50, TRUE);
+    // And if none are found then try partial search.
+    if (empty($ids)) {
+      $ids = DocBlock::searchByTitle($input, $branch, 50);
+    }
+
     $docBlocks = $ids ? DocBlock::loadMultiple($ids) : [];
-    $results = [];
     foreach ($docBlocks as $docBlock) {
       $title = Html::escape($docBlock->getTitle());
       if (!isset($results[$title])) {
diff --git a/src/Controller/SearchController.php b/src/Controller/SearchController.php
index 17c87e6d29da73b9545568b16b7fd44183a6b813..3aa7bdc3f7f523e194943adb64a203a42b33f79b 100644
--- a/src/Controller/SearchController.php
+++ b/src/Controller/SearchController.php
@@ -256,13 +256,13 @@ class SearchController extends ControllerBase {
     $branch = $this->getBranch($branch, $project, TRUE);
     $term = Xss::filter($term);
 
-    // Try exact match and redirect if found.
+    // Try exact match and redirect if only one result.
     $matches = DocBlock::searchByTitle($term, $branch, 10, TRUE);
     if ($matches) {
       // Check for case sensitivity.
       $matches = DocBlock::loadMultiple($matches);
-      foreach ($matches as $match) {
-        if ($match->getObjectName() == $term) {
+      if (count($matches) === 1) {
+        foreach ($matches as $match) {
           $url = Formatter::objectUrl($match);
           if ($url) {
             return new RedirectResponse($url->toString());
diff --git a/tests/src/Functional/SpecialIssuesTest.php b/tests/src/Functional/SpecialIssuesTest.php
index 81f22ece209f9fc04e04690c4ac2cb17c8d17ef7..f6066fe82cc19f329d9daa7ee9cde814fc73099f 100644
--- a/tests/src/Functional/SpecialIssuesTest.php
+++ b/tests/src/Functional/SpecialIssuesTest.php
@@ -168,15 +168,20 @@ class SpecialIssuesTest extends WebPagesBase {
    * Tests searching case sensitivity.
    */
   protected function verifySearchCaseSensitivity() {
-    // Search for lower-case function name should get to the function page.
+    // Search for lower-case function name should get to the search page.
     $this->drupalGet('api/' . $this->branchInfo['project'] . '/' . $this->branchInfo['branch_name'] . '/search');
-    $this->submitForm(['search' => 'sample_function'], 'Search');
-    $this->assertUrlContains('dup_names.php/function/sample_function', 'Got to function page with lower-case search');
+    $this->submitForm(['search' => 'sample_function'], 'Search');    
+    $this->assertUrlContains('api/' . $this->branchInfo['project'] . '/' . $this->branchInfo['branch_name'] . '/search/sample_function', 'Got to search page as multiple results match');
 
-    // Search for upper-case function name should get to the constant page.
+    // Search for upper-case function name should get to the search page.
     $this->drupalGet('api/' . $this->branchInfo['project'] . '/' . $this->branchInfo['branch_name'] . '/search');
     $this->submitForm(['search' => 'SAMPLE_FUNCTION'], 'Search');
-    $this->assertUrlContains('dup_names.php/constant/SAMPLE_FUNCTION', 'Got to constant page with upper-case search');
+    $this->assertUrlContains('api/' . $this->branchInfo['project'] . '/' . $this->branchInfo['branch_name'] . '/search/SAMPLE_FUNCTION', 'Got to search page as multiple results match');
+
+    // Search for lower-case function name should get to the function page.
+    $this->drupalGet('api/' . $this->branchInfo['project'] . '/' . $this->branchInfo['branch_name'] . '/search');
+    $this->submitForm(['search' => 'sample_class_function'], 'Search');    
+    $this->assertUrlContains('sample.php/function/sample_class_function', 'Got to function page as it is unique');
   }
 
   /**