mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-18 08:00:01 +02:00
feat(code search): replace fuzzy search with union search for indexer (#6947)
Fuzzy searching for code has been known to be problematic #5264 and in my personal opinion isn't very useful. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6947 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Shiny Nematoda <snematoda.751k2@aleeas.com> Co-committed-by: Shiny Nematoda <snematoda.751k2@aleeas.com>
This commit is contained in:
parent
cb46a036aa
commit
3816db68aa
10 changed files with 105 additions and 86 deletions
|
@ -20,13 +20,27 @@ type Indexer interface {
|
|||
Search(ctx context.Context, opts *SearchOptions) (int64, []*SearchResult, []*SearchResultLanguages, error)
|
||||
}
|
||||
|
||||
type CodeSearchMode int
|
||||
|
||||
const (
|
||||
CodeSearchModeExact CodeSearchMode = iota
|
||||
CodeSearchModeUnion
|
||||
)
|
||||
|
||||
func (mode CodeSearchMode) String() string {
|
||||
if mode == CodeSearchModeUnion {
|
||||
return "union"
|
||||
}
|
||||
return "exact"
|
||||
}
|
||||
|
||||
type SearchOptions struct {
|
||||
RepoIDs []int64
|
||||
Keyword string
|
||||
Language string
|
||||
Filename string
|
||||
|
||||
IsKeywordFuzzy bool
|
||||
Mode CodeSearchMode
|
||||
|
||||
db.Paginator
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue