support search for literals for repository code search with indexer #14137

Closed
opened 2025-11-02 11:04:04 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @darren on GitHub (Feb 14, 2025).

Feature Description

Sometimes searching for SQL/function in code results in bad hits. eg: search swaggerParameterBodies in my local mirror of gitea:

Image

which is actually defined in https://github.com/go-gitea/gitea/blob/d88b01252519ef3215243df4d1c0c365e41628c9/routers/api/v1/swagger/options.go#L16 not showing in the first page of the search result.

this is the indexer config

[indexer]
REPO_INDEXER_ENABLED = true
REPO_INDEXER_PATH = indexers/repos.bleve
# # 300k
MAX_FILE_SIZE = 307200
REPO_INDEXER_INCLUDE = 
REPO_INDEXER_EXCLUDE = go.sum,package-lock.json

Support searching for literals by enclosing search terms in double quotation marks would be better.

For bleve using Match Phrase Query

Screenshots

No response

Originally created by @darren on GitHub (Feb 14, 2025). ### Feature Description Sometimes searching for SQL/function in code results in bad hits. eg: search `swaggerParameterBodies` in my local mirror of gitea: <img width="1381" alt="Image" src="https://github.com/user-attachments/assets/528b3659-ea21-470f-bd9e-2b8bf6e9b869" /> which is actually defined in https://github.com/go-gitea/gitea/blob/d88b01252519ef3215243df4d1c0c365e41628c9/routers/api/v1/swagger/options.go#L16 not showing in the first page of the search result. this is the indexer config ```ini [indexer] REPO_INDEXER_ENABLED = true REPO_INDEXER_PATH = indexers/repos.bleve # # 300k MAX_FILE_SIZE = 307200 REPO_INDEXER_INCLUDE = REPO_INDEXER_EXCLUDE = go.sum,package-lock.json ``` Support searching for literals by enclosing search terms in double quotation marks would be better. For bleve using [Match Phrase Query](https://blevesearch.com/docs/Query/#match-phrase:8f767fbc41af8ff1ddcf4c60ed8c0fe9) ### Screenshots _No response_
GiteaMirror added the type/proposal label 2025-11-02 11:04:04 -06:00
Author
Owner

@darren commented on GitHub (Feb 14, 2025):

The case I tested above is swaggerParameterBodies, but I searched a local repo with a lot SQL queries and I am not quite satisfied with the search results thus I filed this issue.

As with the swaggerParameterBodies above I assume even using MatchQuery /routers/api/v1/swagger/options.go should come first, why?

@darren commented on GitHub (Feb 14, 2025): The case I tested above is `swaggerParameterBodies`, but I searched a local repo with a lot SQL queries and I am not quite satisfied with the search results thus I filed this issue. As with the `swaggerParameterBodies` above I assume even using `MatchQuery` `/routers/api/v1/swagger/options.go` should come first, why?
Author
Owner

@jpraet commented on GitHub (Feb 14, 2025):

More in general, I think your example screenshot above illustrates a problem I also notice on my instance after upgrading from 1.22 to 1.23.

Why is a search on "swaggerParameterBodies" returning results for "swagger"? Is that intended? Possible related to #32261?

Edit: not related to #32261, but instead to #32210: it changed the bleve query from NewMatchPhraseQuery to NewMatchQuery.

@jpraet commented on GitHub (Feb 14, 2025): More in general, I think your example screenshot above illustrates a problem I also notice on my instance after upgrading from 1.22 to 1.23. Why is a search on "swaggerParameterBodies" returning results for "swagger"? Is that intended? Possible related to #32261? Edit: not related to #32261, but instead to #32210: it changed the bleve query from NewMatchPhraseQuery to NewMatchQuery.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14137