mirror of
https://github.com/go-gitea/gitea
synced 2025-07-03 09:07:19 +00:00
Determine fuzziness of bleve indexer by keyword length (#29706)
also bleve did match on fuzzy search and the other way around. this also fix that bug.
This commit is contained in:
@ -32,7 +32,7 @@ func TestSearchRepo(t *testing.T) {
|
||||
repo, err := repo_model.GetRepositoryByOwnerAndName(db.DefaultContext, "user2", "repo1")
|
||||
assert.NoError(t, err)
|
||||
|
||||
executeIndexer(t, repo, code_indexer.UpdateRepoIndexer)
|
||||
code_indexer.UpdateRepoIndexer(repo)
|
||||
|
||||
testSearch(t, "/user2/repo1/search?q=Description&page=1", []string{"README.md"})
|
||||
|
||||
@ -42,12 +42,14 @@ func TestSearchRepo(t *testing.T) {
|
||||
repo, err = repo_model.GetRepositoryByOwnerAndName(db.DefaultContext, "user2", "glob")
|
||||
assert.NoError(t, err)
|
||||
|
||||
executeIndexer(t, repo, code_indexer.UpdateRepoIndexer)
|
||||
code_indexer.UpdateRepoIndexer(repo)
|
||||
|
||||
testSearch(t, "/user2/glob/search?q=loren&page=1", []string{"a.txt"})
|
||||
testSearch(t, "/user2/glob/search?q=file3&page=1", []string{"x/b.txt"})
|
||||
testSearch(t, "/user2/glob/search?q=file4&page=1", []string{})
|
||||
testSearch(t, "/user2/glob/search?q=file5&page=1", []string{})
|
||||
testSearch(t, "/user2/glob/search?q=loren&page=1&t=match", []string{"a.txt"})
|
||||
testSearch(t, "/user2/glob/search?q=file3&page=1", []string{"x/b.txt", "a.txt"})
|
||||
testSearch(t, "/user2/glob/search?q=file3&page=1&t=match", []string{"x/b.txt", "a.txt"})
|
||||
testSearch(t, "/user2/glob/search?q=file4&page=1&t=match", []string{"x/b.txt", "a.txt"})
|
||||
testSearch(t, "/user2/glob/search?q=file5&page=1&t=match", []string{"x/b.txt", "a.txt"})
|
||||
}
|
||||
|
||||
func testSearch(t *testing.T, url string, expected []string) {
|
||||
@ -57,7 +59,3 @@ func testSearch(t *testing.T, url string, expected []string) {
|
||||
filenames := resultFilenames(t, NewHTMLParser(t, resp.Body))
|
||||
assert.EqualValues(t, expected, filenames)
|
||||
}
|
||||
|
||||
func executeIndexer(t *testing.T, repo *repo_model.Repository, op func(*repo_model.Repository)) {
|
||||
op(repo)
|
||||
}
|
||||
|
Reference in New Issue
Block a user