1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-24 11:18:36 +00:00

Use MatchPhraseQuery for bleve code search (#33628)

Fix regression from #32210 which unintentionally changed the search mode
for bleve from MaatchPhraseQuery to MatchQuery.

On the main branch, meanwhile with #33590 a "literal code search" mode
(by using quotes) was implemented as workaround for this unexpected code
search behavior. Maybe that feature needs some redesign as it turns out
to have been caused by a regression.

But this PR at least already fixes the regression for 1.23.x
This commit is contained in:
Jimmy Praet
2025-02-25 21:20:54 +01:00
committed by GitHub
parent 81126daf53
commit e3021fae79
2 changed files with 42 additions and 30 deletions

View File

@@ -266,7 +266,7 @@ func (b *Indexer) Search(ctx context.Context, opts *internal.SearchOptions) (int
pathQuery.FieldVal = "Filename"
pathQuery.SetBoost(10)
contentQuery := bleve.NewMatchQuery(opts.Keyword)
contentQuery := bleve.NewMatchPhraseQuery(opts.Keyword)
contentQuery.FieldVal = "Content"
if opts.IsKeywordFuzzy {