-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enable literal string for code search #33590
Conversation
The feature is really useful. There are some design concerns:
(I think I could help to make some improvements to address the concerns and add some tests in this PR) |
b57120a
to
e87e418
Compare
so add Since we can make the literal search work in
I think it is only necessary to trim the left and right double qutote. |
Thank you for the update, I think I could try to make it also works with "git grep" and "elasticsearch", will make some more changes in a few days. |
This would be useful indeed. I've been longing for exact search since a long time because neither "fuzzy" nor "match" mode supports exact search. Currently I'm using elasticsearch backend, so would appreciate if this syntax works for elasticsearch too. |
BTW I don't think we should add any more search modes and ideally also not required quotes for exact search. Search should just work like GitHub where there is only one mode and it matches exact and I assume non-exact too. |
} | ||
contentQuery = q | ||
} else { | ||
q := bleve.NewMatchQuery(opts.Keyword) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me like an unintended regression from https://github.com/go-gitea/gitea/pull/32210/files#diff-e1866799c5d7d231d9df896b84d4a9fa54d404d150e26ac6b205eaf0fea3790bL243-R270 that the default changed from NewMatchPhraseQuery to NewMatchQuery. When searching for something like swaggerParameterBodies
it is currently searching separately on swagger
, parameter
and bodies
.
So I wonder if it shouldn't simply be switched back to NewMatchPhraseQuery, without requiring the quotes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bsofiato can you confirm the switch from MatchPhraseQuery to MatchQuery for bleve in #32210 was unintentional?
Hi @jpraet , I made that PR some time ago, but I don't recall being intentional (i.e., thinking about the PR at hand -- search by filename --, it doesn't make much sense to change from MatchPhraseQuery to MatchQuery).
* giteaofficial/main: Add API to support link package to repository and unlink it (go-gitea#33481) [skip ci] Updated translations via Crowdin Update JS and PY dependencies (go-gitea#33587) [chore] add git mailmap for proper attribution of authorship (go-gitea#33612) Move commits signature and verify functions to service layers (go-gitea#33605) add spacing between sign in button's icon and text (go-gitea#33609) enable literal string for code search (go-gitea#33590) [skip ci] Updated translations via Crowdin Artifacts download api for artifact actions v4 (go-gitea#33510) Fix bug when get commit (go-gitea#33602) Fix mirror bug (go-gitea#33597) Fix typo in HTML attribute (go-gitea#33599) Use default Git timeout when checking repo health (go-gitea#33593) Improve commits list performance to reduce unnecessary database queries (go-gitea#33528) Performance optimization for pull request files loading comments attachments (go-gitea#33585) Fix PR's target branch dropdown (go-gitea#33589)
I was unable to create a backport for 1.23. @darren, please send one manually. 🍵
|
I added the backport label here, so we can also backport the bug fixes that address the regression. |
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
Close: #33588