diff --git a/routers/web/repo/search.go b/routers/web/repo/search.go
index 273b90c97e..460378ce05 100644
--- a/routers/web/repo/search.go
+++ b/routers/web/repo/search.go
@@ -41,7 +41,7 @@ func Search(ctx *context.Context) {
 	}
 
 	if setting.Indexer.RepoIndexerEnabled {
-		ctx.Data["CodeIndexerEnabled"] = true
+		ctx.Data["CodeIndexerDisabled"] = false
 
 		total, searchResults, searchResultLanguages, err := code_indexer.PerformSearch(ctx, &code_indexer.SearchOptions{
 			RepoIDs:        []int64{ctx.Repo.Repository.ID},
@@ -77,7 +77,7 @@ func Search(ctx *context.Context) {
 			return
 		}
 
-		ctx.Data["CodeIndexerEnabled"] = false
+		ctx.Data["CodeIndexerDisabled"] = true
 		ctx.Data["SearchResults"] = data
 
 		pager := context.NewPagination(len(data), setting.UI.RepoSearchPagingNum, page, 5)
diff --git a/templates/shared/search/code/results.tmpl b/templates/shared/search/code/results.tmpl
index 09604e0f6c..02d1252770 100644
--- a/templates/shared/search/code/results.tmpl
+++ b/templates/shared/search/code/results.tmpl
@@ -24,10 +24,10 @@
 				{{else}}
 					<span class="file gt-f1">{{.Filename}}</span>
 				{{end}}
-				<a role="button" class="ui basic tiny button" rel="nofollow" href="{{$repo.Link}}/src/{{if eq $.CodeIndexerEnabled false}}branch{{else}}commit{{end}}/{{$result.CommitID | PathEscape}}/{{.Filename | PathEscapeSegments}}">{{ctx.Locale.Tr "repo.diff.view_file"}}</a>
+				<a role="button" class="ui basic tiny button" rel="nofollow" href="{{$repo.Link}}/src/{{if $.CodeIndexerDisabled}}branch{{else}}commit{{end}}/{{$result.CommitID | PathEscape}}/{{.Filename | PathEscapeSegments}}">{{ctx.Locale.Tr "repo.diff.view_file"}}</a>
 			</h4>
 			<div class="ui attached table segment">
-				{{template "shared/searchfile" dict "RepoLink" $repo.Link "CodeIndexerEnabled" $.CodeIndexerEnabled "SearchResult" .}}
+				{{template "shared/searchfile" dict "RepoLink" $repo.Link "CodeIndexerDisabled" $.CodeIndexerDisabled "SearchResult" .}}
 			</div>
 			{{template "shared/searchbottom" dict "root" $ "result" .}}
 		</div>
diff --git a/templates/shared/search/code/search.tmpl b/templates/shared/search/code/search.tmpl
index 4b1257bed5..0cfd62a1f7 100644
--- a/templates/shared/search/code/search.tmpl
+++ b/templates/shared/search/code/search.tmpl
@@ -1,5 +1,5 @@
 <form class="ui form ignore-dirty">
-	{{if ne $.CodeIndexerEnabled false}}
+	{{if not $.CodeIndexerDisabled}}
 		{{template "shared/search/combo_fuzzy" dict "Value" .Keyword "Disabled" .CodeIndexerUnavailable "IsFuzzy" .IsFuzzy "Placeholder" (ctx.Locale.Tr "search.code_kind")}}
 	{{else}}
 		{{template "shared/search/combo" dict "Value" .Keyword "Placeholder" (ctx.Locale.Tr "search.code_kind")}}
diff --git a/templates/shared/searchfile.tmpl b/templates/shared/searchfile.tmpl
index 4c098138de..f2c1369555 100644
--- a/templates/shared/searchfile.tmpl
+++ b/templates/shared/searchfile.tmpl
@@ -4,7 +4,7 @@
 			{{range .SearchResult.Lines}}
 				<tr>
 					<td class="lines-num">
-						<a href="{{$.RepoLink}}/src/{{if eq $.CodeIndexerEnabled false}}branch{{else}}commit{{end}}/{{PathEscape $.SearchResult.CommitID}}/{{PathEscapeSegments $.SearchResult.Filename}}#L{{.Num}}"><span>{{.Num}}</span></a>
+						<a href="{{$.RepoLink}}/src/{{if $.CodeIndexerDisabled}}branch{{else}}commit{{end}}/{{PathEscape $.SearchResult.CommitID}}/{{PathEscapeSegments $.SearchResult.Filename}}#L{{.Num}}"><span>{{.Num}}</span></a>
 					</td>
 					<td class="lines-code chroma"><code class="code-inner">{{.FormattedContent}}</code></td>
 				</tr>