Search for text that includes underscore returns nothing #2493

Open
opened 2025-11-02 04:38:26 -06:00 by GiteaMirror · 12 comments
Owner

Originally created by @mfigrs on GitHub (Nov 5, 2018).

  • Gitea version (or commit ref): 6df46c5
  • Git version: 2.15.2
  • Operating system: Docker on Synology
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • [ x ] SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

I've enabled repository search in app.ini, however this feature is next to useless. If I search for a function name, say "list_users", the search returns nothing. Same for "list_" or "_users" - it seems as if the search doesn't like the underscore symbol.

Originally created by @mfigrs on GitHub (Nov 5, 2018). <!-- 1. Please speak English, this is the language all of us can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/NsatcWJ) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 6df46c5 - Git version: 2.15.2 - Operating system: Docker on Synology - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ x ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [ ] Not relevant - Log gist: ## Description I've enabled repository search in app.ini, however this feature is next to useless. If I search for a function name, say "list_users", the search returns nothing. Same for "list_" or "_users" - it seems as if the search doesn't like the underscore symbol. <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the issue/confirmedtype/bug labels 2025-11-02 04:38:26 -06:00
Author
Owner

@lunny commented on GitHub (Nov 5, 2018):

It works here.

image

@lunny commented on GitHub (Nov 5, 2018): It works here. ![image](https://user-images.githubusercontent.com/81045/48003520-9f85ac00-e149-11e8-8e8c-6389d049a476.png)
Author
Owner

@mfigrs commented on GitHub (Nov 5, 2018):

But here it does not:

2018-11-05

@mfigrs commented on GitHub (Nov 5, 2018): But here it does not: ![2018-11-05](https://user-images.githubusercontent.com/13370645/48004633-93650480-e0df-11e8-94ac-3d0fd69e9d45.png)
Author
Owner

@lunny commented on GitHub (Nov 5, 2018):

If you just enabled the feature on app.ini, it will spend some time to create the index, maybe the index is not finished.

@lunny commented on GitHub (Nov 5, 2018): If you just enabled the feature on app.ini, it will spend some time to create the index, maybe the index is not finished.
Author
Owner

@mfigrs commented on GitHub (Nov 5, 2018):

I've enabled this feature over a week ago. Anyway, if I just enter "user" without any underscore, I have 3 pages of results:

2018-11-05 1

@mfigrs commented on GitHub (Nov 5, 2018): I've enabled this feature over a week ago. Anyway, if I just enter "user" without any underscore, I have 3 pages of results: ![2018-11-05 1](https://user-images.githubusercontent.com/13370645/48006738-1ab47700-e0e4-11e8-838c-6e61640de32c.png)
Author
Owner

@zeripath commented on GitHub (Nov 5, 2018):

Hmm... I bet this has to do with the way bleve segments out words. Could it be that it's seeing and indexing "list_users" as "list users"?

@zeripath commented on GitHub (Nov 5, 2018): Hmm... I bet this has to do with the way bleve segments out words. Could it be that it's seeing and indexing "list_users" as "list users"?
Author
Owner

@mfigrs commented on GitHub (Nov 5, 2018):

Hmm... I bet this has to do with the way bleve segments out words. Could it be that it's seeing and indexing "list_users" as "list users"?

A search for "list users" also returns nothing, unfortunately...

Some other points:

  • search for "admin-users" text returns correct results
  • search for "admin-users.php" returns nothing, but it should return identical results to the above.

Furthermore:
Searching for ".users", "/users", "\users" seem to return the same results as plain search for "users"...

@mfigrs commented on GitHub (Nov 5, 2018): > > Hmm... I bet this has to do with the way bleve segments out words. Could it be that it's seeing and indexing "list_users" as "list users"? A search for "list users" also returns nothing, unfortunately... Some other points: - search for "admin-users" text returns correct results - search for "admin-users.php" returns nothing, but it should return identical results to the above. Furthermore: Searching for ".users", "/users", "\users" seem to return the same results as plain search for "users"...
Author
Owner

@zeripath commented on GitHub (Nov 5, 2018):

Hmm. OK a quick test of blevesearch/segment seems to imply that "list_users" would form a single segment.

@zeripath commented on GitHub (Nov 5, 2018): Hmm. OK a quick test of blevesearch/segment seems to imply that "list_users" would form a single segment.
Author
Owner

@stale[bot] commented on GitHub (Jan 21, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Jan 21, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@barryp commented on GitHub (Jan 22, 2019):

I just tried it with gitea 1.6.4 and it's still an issue. Single word queries give results, but snake_cased queries return nothing even though the variable names are present in the repo.

@barryp commented on GitHub (Jan 22, 2019): I just tried it with gitea 1.6.4 and it's still an issue. Single word queries give results, but snake_cased queries return nothing even though the variable names are present in the repo.
Author
Owner

@lunny commented on GitHub (Jan 23, 2019):

The words splitter just uses spaces to split the words. I think that's why when you have list_users but cannot search list or users. The current code search is very simple which need improvements.

@lunny commented on GitHub (Jan 23, 2019): The words splitter just uses spaces to split the words. I think that's why when you have `list_users` but cannot search `list` or `users`. The current code search is very simple which need improvements.
Author
Owner

@stale[bot] commented on GitHub (Mar 24, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Mar 24, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@bartwensley commented on GitHub (Jun 18, 2019):

This issue renders the search functionality pretty much useless for code that regularly includes underscores (e.g. python). A couple more examples...

The following search returns a single result (there should be 33 matches from my count):
https://opendev.org/starlingx/config/search?q=_get_service_config

The following search returns no results (there should be 3 matches from my count):
https://opendev.org/starlingx/config/search?q=_get_admin_user_name

@bartwensley commented on GitHub (Jun 18, 2019): This issue renders the search functionality pretty much useless for code that regularly includes underscores (e.g. python). A couple more examples... The following search returns a single result (there should be 33 matches from my count): https://opendev.org/starlingx/config/search?q=_get_service_config The following search returns no results (there should be 3 matches from my count): https://opendev.org/starlingx/config/search?q=_get_admin_user_name
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#2493