Patch in exact search for meilisearch (#29671)
meilisearch does not have an search option to contorl fuzzynes per query right now: - https://github.com/meilisearch/meilisearch/issues/1192 - https://github.com/orgs/meilisearch/discussions/377 - https://github.com/meilisearch/meilisearch/discussions/1096 so we have to create a workaround by post-filter the search result in gitea until this is addressed. For future works I added an option in backend only atm, to enable fuzzynes for issue indexer too. And also refactored the code so the fuzzy option is equal in logic to code indexer --- *Sponsored by Kithara Software GmbH* Conflicts: routers/web/repo/search.go trivial context confict s/isMatch/isFuzzy/
This commit is contained in:
parent
299c2a1408
commit
38c3cc4eb7
14 changed files with 184 additions and 33 deletions
|
@ -35,7 +35,7 @@ func Code(ctx *context.Context) {
|
|||
keyword := ctx.FormTrim("q")
|
||||
|
||||
queryType := ctx.FormTrim("t")
|
||||
isMatch := queryType == "match"
|
||||
isFuzzy := queryType != "match"
|
||||
|
||||
ctx.Data["Keyword"] = keyword
|
||||
ctx.Data["Language"] = language
|
||||
|
@ -77,7 +77,7 @@ func Code(ctx *context.Context) {
|
|||
)
|
||||
|
||||
if (len(repoIDs) > 0) || isAdmin {
|
||||
total, searchResults, searchResultLanguages, err = code_indexer.PerformSearch(ctx, repoIDs, language, keyword, page, setting.UI.RepoSearchPagingNum, isMatch)
|
||||
total, searchResults, searchResultLanguages, err = code_indexer.PerformSearch(ctx, repoIDs, language, keyword, page, setting.UI.RepoSearchPagingNum, isFuzzy)
|
||||
if err != nil {
|
||||
if code_indexer.IsAvailable(ctx) {
|
||||
ctx.ServerError("SearchResults", err)
|
||||
|
|
|
@ -21,7 +21,7 @@ func Search(ctx *context.Context) {
|
|||
keyword := ctx.FormTrim("q")
|
||||
|
||||
queryType := ctx.FormTrim("t")
|
||||
isMatch := queryType == "match"
|
||||
isFuzzy := queryType != "match"
|
||||
|
||||
ctx.Data["Keyword"] = keyword
|
||||
ctx.Data["Language"] = language
|
||||
|
@ -44,7 +44,7 @@ func Search(ctx *context.Context) {
|
|||
ctx.Data["CodeIndexerEnabled"] = true
|
||||
|
||||
total, searchResults, searchResultLanguages, err := code_indexer.PerformSearch(ctx, []int64{ctx.Repo.Repository.ID},
|
||||
language, keyword, page, setting.UI.RepoSearchPagingNum, isMatch)
|
||||
language, keyword, page, setting.UI.RepoSearchPagingNum, isFuzzy)
|
||||
if err != nil {
|
||||
if code_indexer.IsAvailable(ctx) {
|
||||
ctx.ServerError("SearchResults", err)
|
||||
|
|
|
@ -40,7 +40,7 @@ func CodeSearch(ctx *context.Context) {
|
|||
keyword := ctx.FormTrim("q")
|
||||
|
||||
queryType := ctx.FormTrim("t")
|
||||
isMatch := queryType == "match"
|
||||
isFuzzy := queryType != "match"
|
||||
|
||||
ctx.Data["Keyword"] = keyword
|
||||
ctx.Data["Language"] = language
|
||||
|
@ -75,7 +75,7 @@ func CodeSearch(ctx *context.Context) {
|
|||
)
|
||||
|
||||
if len(repoIDs) > 0 {
|
||||
total, searchResults, searchResultLanguages, err = code_indexer.PerformSearch(ctx, repoIDs, language, keyword, page, setting.UI.RepoSearchPagingNum, isMatch)
|
||||
total, searchResults, searchResultLanguages, err = code_indexer.PerformSearch(ctx, repoIDs, language, keyword, page, setting.UI.RepoSearchPagingNum, isFuzzy)
|
||||
if err != nil {
|
||||
if code_indexer.IsAvailable(ctx) {
|
||||
ctx.ServerError("SearchResults", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue