Skip to content
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

Add search syntax tip for whole word searches #35276

Closed
wants to merge 1 commit into from

Conversation

nbenitez
Copy link
Contributor

Whole word searches are very useful in situations when a normal search gives two many false positives. Let's document how to do that in Github code search, so people don't have to look that up in regext tutorials.

Why:

Because some times when receiving too many false positives matches, using whole word matching is a popular and effective way to narrow results down to your sought target.

What's being changed (if available, include any code snippets, screenshots, or gifs):

Check off the following:

  • I have reviewed my changes in staging, available via the View deployment link in this PR's timeline (this link will be available after opening the PR).

    • For content changes, you will also see an automatically generated comment with links directly to pages you've modified. The comment won't appear if your PR only edits files in the data directory.
  • For content changes, I have completed the self-review checklist.

Whole word searches are very useful in situations when a normal search gives two many false positives. Let's document how to do that in Github code search, so people don't have to look that up in regext tutorials.
@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Nov 13, 2024
Copy link
Contributor

Automatically generated comment ℹ️

This comment is automatically generated and will be overwritten every time changes are committed to this branch.

The table contains an overview of files in the content directory that have been changed in this pull request. It's provided to make it easy to review your changes on the staging site. Please note that changes to the data directory will not show up in this table.


Content directory changes

You may find it useful to copy this table into the pull request summary. There you can edit it to share links to important articles or changes and to give a high-level overview of how the changes in your pull request support the overall goals of the pull request.

Source Preview Production What Changed
search-github/github-code-search/understanding-github-code-search-syntax.md fpt
ghec
fpt
ghec

fpt: Free, Pro, Team
ghec: GitHub Enterprise Cloud
ghes: GitHub Enterprise Server

@nguyenalex836 nguyenalex836 added content This issue or pull request belongs to the Docs Content team waiting for review Issue/PR is waiting for a writer's review search-github Related to GitHub search and removed triage Do not begin working on this issue until triaged by the team labels Nov 13, 2024
@nguyenalex836
Copy link
Contributor

@nbenitez Thanks so much for opening a PR! I'll get this triaged for review ✨

@subatoi
Copy link
Contributor

subatoi commented Nov 14, 2024

Hi @nbenitez and thanks for your submission 👋

However, I'm afraid we won't be accepting this on this occasion: I'm not convinced about the particular benefit this new section would have, as we already describe the use of regular expressions in the same article.

Many thanks for your interest in the GitHub Docs and please feel free to take a look at our issues marked help wanted!

@subatoi subatoi closed this Nov 14, 2024
@nbenitez
Copy link
Contributor Author

nbenitez commented Nov 22, 2024

Much like case sensitiveness, Whole word is a search feature present in most search dialogs (eg. try Adobe Reader, Firefox, etc..) for a reason, because it is both useful and used commonly to limit false positives.

Try eg. search for the matio library inside Flathub organization -> org:flathub matio Github will crash for too many results, then try with case sensitiveness activated -> org:flathub /(?-i)matio/ will not crash but show and an error box with message Results are incomplete due to an internal timeout, consider retrying or refining your query. This is caused by the word information containing matio and information appears in a lot of places including every code license.

So the solution is to use Whole Word -> org:flathub /(?-i)\bmatio\b/

And it is not a coincidence that most search dialogs include that option instead of having the user to learn regex to use that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content This issue or pull request belongs to the Docs Content team search-github Related to GitHub search waiting for review Issue/PR is waiting for a writer's review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants