aboutsummaryrefslogtreecommitdiffstats
path: root/routers/home.go
diff options
context:
space:
mode:
authorJui-Nan Lin <jnlinn@gmail.com>2021-01-27 18:00:35 +0800
committerGitHub <noreply@github.com>2021-01-27 12:00:35 +0200
commitc10503afeccd5172ace7613094dd5fe1e0770c55 (patch)
tree5a39cbf125f38a3bc75eb77c689b03ed13efa44c /routers/home.go
parentb2c20b68a08e23bc952402a553d59a4613188bd0 (diff)
downloadgitea-c10503afeccd5172ace7613094dd5fe1e0770c55.tar.gz
gitea-c10503afeccd5172ace7613094dd5fe1e0770c55.zip
[Feature] add precise search type for Elastic Search (#12869)
* feat: add type query parameters for specifying precise search * feat: add select dropdown in search box Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'routers/home.go')
-rw-r--r--routers/home.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/routers/home.go b/routers/home.go
index d37bf8e31b..f82ee9808b 100644
--- a/routers/home.go
+++ b/routers/home.go
@@ -299,6 +299,9 @@ func ExploreCode(ctx *context.Context) {
page = 1
}
+ queryType := strings.TrimSpace(ctx.Query("t"))
+ isMatch := queryType == "match"
+
var (
repoIDs []int64
err error
@@ -342,14 +345,14 @@ func ExploreCode(ctx *context.Context) {
ctx.Data["RepoMaps"] = rightRepoMap
- total, searchResults, searchResultLanguages, err = code_indexer.PerformSearch(repoIDs, language, keyword, page, setting.UI.RepoSearchPagingNum)
+ total, searchResults, searchResultLanguages, err = code_indexer.PerformSearch(repoIDs, language, keyword, page, setting.UI.RepoSearchPagingNum, isMatch)
if err != nil {
ctx.ServerError("SearchResults", err)
return
}
// if non-login user or isAdmin, no need to check UnitTypeCode
} else if (ctx.User == nil && len(repoIDs) > 0) || isAdmin {
- total, searchResults, searchResultLanguages, err = code_indexer.PerformSearch(repoIDs, language, keyword, page, setting.UI.RepoSearchPagingNum)
+ total, searchResults, searchResultLanguages, err = code_indexer.PerformSearch(repoIDs, language, keyword, page, setting.UI.RepoSearchPagingNum, isMatch)
if err != nil {
ctx.ServerError("SearchResults", err)
return
@@ -380,6 +383,7 @@ func ExploreCode(ctx *context.Context) {
ctx.Data["Keyword"] = keyword
ctx.Data["Language"] = language
+ ctx.Data["queryType"] = queryType
ctx.Data["SearchResults"] = searchResults
ctx.Data["SearchResultLanguages"] = searchResultLanguages
ctx.Data["RequireHighlightJS"] = true