aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo
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/repo
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/repo')
-rw-r--r--routers/repo/search.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/routers/repo/search.go b/routers/repo/search.go
index e110ae2a72..42fe3d7584 100644
--- a/routers/repo/search.go
+++ b/routers/repo/search.go
@@ -28,14 +28,18 @@ func Search(ctx *context.Context) {
if page <= 0 {
page = 1
}
+ queryType := strings.TrimSpace(ctx.Query("t"))
+ isMatch := queryType == "match"
+
total, searchResults, searchResultLanguages, err := code_indexer.PerformSearch([]int64{ctx.Repo.Repository.ID},
- language, keyword, page, setting.UI.RepoSearchPagingNum)
+ language, keyword, page, setting.UI.RepoSearchPagingNum, isMatch)
if err != nil {
ctx.ServerError("SearchResults", err)
return
}
ctx.Data["Keyword"] = keyword
ctx.Data["Language"] = language
+ ctx.Data["queryType"] = queryType
ctx.Data["SourcePath"] = setting.AppSubURL + "/" +
path.Join(ctx.Repo.Repository.Owner.Name, ctx.Repo.Repository.Name)
ctx.Data["SearchResults"] = searchResults