Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 56fe624

Browse files
committed
initial updates for new code search
1 parent bcbfdc9 commit 56fe624

12 files changed

Lines changed: 370 additions & 0 deletions

File tree

content/search-github/getting-started-with-searching-on-github/about-searching-on-github.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ versions:
1818
topics:
1919
- GitHub search
2020
---
21+
22+
{% ifversion github-code-search %}
23+
{% note %}
24+
25+
**Note:** {% data reusables.search.classic-search-code-search-note %}
26+
27+
{% endnote %}
28+
{% endif %}
29+
2130
{% data reusables.search.you-can-search-globally %}
2231

2332
- To search globally across all of {% data variables.product.product_name %}, type what you're looking for into the search field at the top of any page, and choose "All {% data variables.product.prodname_dotcom %}" in the search drop-down menu.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: About GitHub Code Search (beta)
3+
intro: 'You can search, navigate and understand code across GitHub with GitHub Code Search (beta).'
4+
allowTitleToDifferFromFilename: true
5+
versions:
6+
feature: github-code-search
7+
topics:
8+
- GitHub search
9+
---
10+
11+
{% note %}
12+
13+
**Note:** {% data reusables.search.code-search-code-view-beta-note %}<br><br>
14+
15+
{% data reusables.search.code-view-link %}
16+
17+
{% endnote %}
18+
19+
## About GitHub Code Search (beta)
20+
21+
GitHub Code Search (beta) lets you rapidly search, navigate and understand your code, your team's code, and the code of the open source community, all from GitHub.com. This search engine is designed to be scalable, code-aware, and support searching code across GitHub using regular expressions, boolean operations, specialized qualifiers, and keyboard shortcuts. For more information on the syntax of GitHub Code Search (beta), see "[Understanding GitHub Code Search (beta) syntax](/articles/understanding-github-code-search-syntax)."
22+
23+
On top of the new code search engine, GitHub Code Search (beta) includes new features in the search interface on GitHub.com, allowing you to more quickly and easily find what you are looking for, including suggestions, completions, and the ability to save your searches. For more information, see "[Using GitHub Code Search (beta)](/articles/using-github-code-search)."
24+
25+
Note that the syntax and qualifiers for searching for non-code content, such as issues, users, and discussions, works the same as it did before, in the classic search. For more information on the classic search, see "[About search on GitHub](/articles/about-search-on-github) and "[Searching on GitHub](/search-github/searching-on-github/index.md)."
26+
27+
GitHub Code Search (beta) is tightly integrated with a redesigned code view (beta) on GitHub.com. {% data reusables.search.code-view-link %}
28+
29+
To get access to GitHub Code Search (beta), along with the new code view, you can sign up for the [waitlist](https://github.com/features/code-search-code-view/signup).
30+
31+
## Enabling and disabling GitHub Code Search (beta)
32+
33+
Once you are given access to the GitHub Code Search and Code View beta, you can enable or disable GitHub Code Search on GitHub.com anytime. Note that this setting applies to both the search and the code view.
34+
35+
{% data reusables.feature-preview.feature-preview-setting %}
36+
1. To the right of "New Code Search and Code View (Beta)", click **Enable** or **Disable**.
37+
38+
## Limitations
39+
40+
We have indexed more than 10 million public repositories for GitHub Code Search (beta). Additionally, the private repositories of GitHub users in the beta are indexed and searchable by beta participants that already have access to those private repositories on GitHub.com. However, very large repositories may not be indexed at this time, and not all code is indexed.
41+
42+
The current limitations on indexed code are:
43+
- Vendored and generated code is excluded (as determined by [Enry](https://github.com/go-enry/go-enry))
44+
- Empty files and files over 350 KiB are excluded
45+
- Only UTF-8 encoded files are included
46+
- Very large repositories may not be indexed
47+
48+
We currently only support searching for code on the default branch of a repository.
49+
50+
Results for any search with GitHub Code Search (beta) are restricted to 100 results (10 pages). This limitation only applies to searching code with GitHub Code Search (beta) and does not apply to other types of searches.
51+
52+
ADD SYMBOL SEARCH INFO HERE
53+
54+
## Feedback and support
55+
56+
You can view and share feedback about GitHub Code Search (beta) in our [discussion forum](https://github.com/orgs/community/discussions/categories/code-search-and-navigation).
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: GitHub Code Search (beta)
3+
intro: 'You can use a wide range of syntax to search {% data variables.product.product_name %}. You can adjust the scope of your search, build and troubleshoot queries, and sort search results with qualifiers.'
4+
allowTitleToDifferFromFilename: true
5+
versions:
6+
feature: github-code-search
7+
topics:
8+
- GitHub search
9+
children:
10+
- /about-github-code-search
11+
- /using-github-code-search
12+
- /understanding-github-code-search-syntax
13+
---
14+
15+
{% note %}
16+
17+
**Note:** {% data reusables.search.code-search-code-view-beta-note %}<br><br>
18+
19+
{% data reusables.search.code-search-link %} {% data reusables.search.code-view-link %}
20+
21+
{% endnote %}
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
---
2+
title: Understanding GitHub Code Search (beta) syntax
3+
intro: 'You can build search queries that return the results you want with specialized code qualifiers, regular expressions, and boolean operations.'
4+
allowTitleToDifferFromFilename: true
5+
versions:
6+
feature: github-code-search
7+
topics:
8+
- GitHub search
9+
---
10+
11+
{% note %}
12+
13+
**Note:** {% data reusables.search.code-search-code-view-beta-note %}<br><br>
14+
15+
{% data reusables.search.code-search-link %} {% data reusables.search.code-view-link %}
16+
17+
{% endnote %}
18+
19+
## About the GitHub Code Search query structure
20+
21+
Please note that the search syntax in this article only applies to searching code with the GitHub Code Search (beta). The syntax and qualifiers used when searching for other search types such as issues, pull requests, and wikis works the same way as it does with the classic search on GitHub.com. For more information, see "[Searching on GitHub](/search-github/searching-on-github/index.md)."
22+
23+
Search queries consist of search terms, consisting of text you want to search for, and qualifiers, which narrow down the search.
24+
25+
A bare term with no qualifiers will match either the content of a file or the file's path.
26+
27+
For example, the following query:
28+
29+
```
30+
http-push
31+
```
32+
33+
The above query will match the file `docs/http-push.txt`, even if it doesn't contain the term `http-push`. It will also match a file called `example.txt` if it contains the term `http-push`.
34+
35+
You can enter multiple terms separated by whitespace to search for documents that satisfy both terms.
36+
37+
For example, the following query:
38+
39+
```
40+
sparse index
41+
```
42+
43+
The search results would include all documents containing both the terms `sparse` and `index`, in any order. As examples, it would match a file containing `SparseIndexVector`, or even the phrase `index for sparse trees`.
44+
45+
Searching for multiple terms separated by whitespace is the equivalent to the search `hello AND world`. Other boolean operations, such as `hello OR world`, are also supported in GitHub Code Search (beta). For more information about boolean operations, see "[Using boolean operations](#using-boolean-operations)."
46+
47+
GitHub Code Search (beta) also supports searching for an exact string, including whitespace. For more information, see "[Query for an exact match](#query-for-an-exact-match)."
48+
49+
You can narrow your code search with specialized qualifiers, such as `repo:`, `language:` and `path:`. For more information on the qualifiers you can use in GitHub Code Search (beta), see "[Using qualifiers](#using-qualifiers)."
50+
51+
You can also use regular expressions in your searches by surrounding the expression in slashes. For more information on using regular expressions, see "[Using regular expressions](#using-regular-expressions)."
52+
53+
## Query for an exact match
54+
55+
To search for an exact string, including whitespace, you can surround the string in quotes. For example:
56+
57+
```
58+
"sparse index"
59+
```
60+
61+
To search for a phrase containing a quotation mark, you can escape the quotation mark using a backslash. For example, to find the exact string `name = "tensorflow"`, you can search:
62+
63+
```
64+
"name = \"tensorflow\""
65+
```
66+
67+
You can also use quoted strings in qualifiers, for example:
68+
69+
```
70+
path: git language: "protocol buffers"
71+
```
72+
73+
## Using boolean operations
74+
75+
The GitHub Code Search (beta) supports boolean expressions. You can use the operators `AND`, `OR`, and `NOT` to combine search terms.
76+
77+
By default, adjacent terms separated by whitespace are equivalent to using the `AND` operator. For example, the search query `sparse index` is the same as `sparse AND index`, meaning that the search results will include all documents containing both the terms `sparse` and `index`, in any order.
78+
79+
To search for documents containing either one term or the other, you can use the `OR` operator. For example, the following query will match documents containing either `sparse` or `index`:
80+
81+
```
82+
sparse OR index
83+
```
84+
85+
To exclude files from your search results, you can use the `NOT` operator. For example, to exclude file in the `__testing__` directory, you can search:
86+
87+
```
88+
"fatal error" NOT path:__testing__
89+
```
90+
91+
You can use parentheses to express more complicated boolean expressions. For example:
92+
93+
```
94+
(language:ruby OR language:python) AND NOT path:"/tests/"
95+
```
96+
97+
## Using qualifiers
98+
99+
You can use specialized keywords to qualify your search.
100+
101+
### Repository qualifier
102+
103+
To search within a repository, use the `repo:` qualifier. You must provide the full repository name, including the owner. For example:
104+
105+
```
106+
repo:github/linguist
107+
```
108+
109+
To search within a set of repositories, you can combine multiple `repo:` qualifiers with the boolean operator `OR`. For example:
110+
111+
```
112+
repo:github/linguist OR repo:tree-sitter/tree-sitter
113+
```
114+
115+
{% note %}
116+
117+
**Note:** GitHub Code Search does not currently support regular expressions or partial matching for repository names, so you will have to type the entire repository name (including the user prefix) for the `repo:` qualifier to work.
118+
119+
{% endnote %}
120+
121+
### Organization and user qualifiers
122+
123+
To search for files within an organization, use the `org:` qualifier. For example:
124+
125+
```
126+
org:github
127+
```
128+
129+
To search for files within an organization, use the `user:` qualifier. For example:
130+
131+
```
132+
user:octocat
133+
```
134+
135+
{% note %}
136+
137+
**Note:** GitHub Code Search does not currently support regular expressions or partial matching for organization or user names, so you will have to type the entire organization or user name for the qualifier to work.
138+
139+
{% endnote %}
140+
141+
142+
### Language qualifier
143+
144+
To narrow down to a specific languages, use the `language:` qualifier. For example:
145+
146+
```
147+
language: ruby OR language:cpp OR language:csharp
148+
```
149+
150+
For a complete list of supported language names, see [languages.yaml](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml) in [github/linguist](https://github.com/github/linguist). If your preferred language is not on the list, you can open a pull request to add it.
151+
152+
### Path qualifier
153+
154+
TBD
155+
156+
157+
### Symbol qualifier
158+
159+
TBD
160+
161+
### Content qualifier
162+
163+
By default, bare terms search both paths and file content. To restrict a search to strictly match the content of a file and not file paths, use the `content:` qualifier. For example:
164+
165+
```
166+
content:README.md
167+
```
168+
169+
This query would only match files containing the term `README.md`, rather than matching files named `README.md`.
170+
171+
172+
### Is qualifier
173+
174+
To filter based on document properties, you can use the `is:` qualifier. At this time, the only value supported in this qualifier is `archived`, which restricts the search to archived repositories. For example:
175+
176+
```
177+
path:/MIT.txt is:archived
178+
```
179+
180+
Note that the `is:` qualifier can be inverted with the `NOT` operator. To search for non-archived repositories, you can search:
181+
182+
```
183+
log4j NOT is:archived
184+
```
185+
186+
## Using regular expressions
187+
188+
GitHub Code Search (beta) supports regular expressions to search for patterns in your code. You can use regular expressions in bare search terms as well as within many qualifiers, by surrounding the regex expression in backslashes.
189+
190+
For example, to search for the regular expression `sparse.*index`, you would use:
191+
192+
```
193+
/sparse.*index/
194+
```
195+
196+
Note that you'll have to escape any forward slashes within the regular expression. For example, to search for files within the `App/src` directory, you would use:
197+
198+
```
199+
/^App\/src\//
200+
```
201+
202+
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: Using GitHub Code Search (beta)
3+
intro: ''
4+
allowTitleToDifferFromFilename: true
5+
versions:
6+
feature: github-code-search
7+
topics:
8+
- GitHub search
9+
---
10+
11+
{% note %}
12+
13+
**Note:** {% data reusables.search.code-search-code-view-beta-note %}<br><br>
14+
15+
{% data reusables.search.code-search-link %} {% data reusables.search.code-view-link %}
16+
17+
{% endnote %}
18+
19+
## About using GitHub Code Search (beta)
20+
21+
Upon getting access to the GitHub Code Search beta, GitHub will index any repositories you own and any repositories in organizations you are a member of, whether public, private, or internal. This means that you can search across all of your repositories, in addition to the public repositories on GitHub.com that have already been indexed. Only users with permission to view your code on GitHub.com will be able to see your code in search results.
22+
23+
Not all code is indexed, and you can currently only search the default branches of repositories. For more information on known limitations, see "[About GitHub Code Search (beta)](/search-github/github-code-search/about-github-code-search#limitations)."
24+
25+
The GitHub Code Search beta is integrated within the new code view beta. {% data reusables.search.code-view-link %}
26+
27+
## Using the search bar
28+
29+
You can use the existing search bar on the top navigation of GitHub.com. Using suggestions, completions, and saved searches, you can quickly find what you are looking for, often without having to fully type a query or view the search results page.
30+
31+
For more information about the search syntax of GitHub Code Search (beta), see "[Understanding GitHub Code Search (beta) syntax](/search-github/github-code-search/understanding-github-code-search-syntax)."
32+
33+
Note that the syntax and qualifiers for searching for non-code content, such as issues, users, and discussions, works the same as it did before, in the classic search. For more information on the classic search, see "[About search on GitHub](/articles/about-search-on-github) and "[Searching on GitHub](/search-github/searching-on-github/index.md)."
34+
35+
1. In the top navigation of GitHub.com, click the search bar.
36+
2. Under the search bar, you will see a list of suggestions organized by category, including recent searches and suggested repositories, teams, and projects that you have access to. You can also see a list of saved searches that you have created. For more information on saved searches, see [Using the search results view](#creating-and-managing-saved-searches).
37+
38+
If you click on any of the specific suggestions, you will be taken directly to the page for that suggestion (for example, the repository or project page). If you click on a recent or saved search, you will be taken to the search results view for that search query.
39+
3. Once you start typing a search query, you will see a list of completions and suggestions that match your query. You can click on those to jump to a specific location. As you type more qualifiers, you will see more specific suggestions, such as code files.
40+
4. After typing your query, you can also hit Enter to be taken to the full search results view. For more information, see [Using the search results view](#using-the-search-results-view).
41+
42+
## Creating and managing saved searches
43+
44+
1. In the top navigation of GitHub.com, click the search bar and start typing a search query (or any word).
45+
2. Under the search bar, the "Saved searches" section should now show. Click **Create saved search**.
46+
3. In the pop-up window, fill out the name you want for your query and the query that you want to save. Click **Create saved search**.
47+
48+
If you click again on the search bar, you can now see your saved search in the "Saved searches" section under the search bar. Clicking on a saved search will add the query to the search bar and filter the suggestions accordingly.
49+
50+
To edit a saved search, select the search bar and, in the "Saved searches" section, click the pencil icon to the right of the saved search. To delete a saved search, click the trash can icon to the right of the saved search.
51+
52+
## Using the search results view
53+
54+
This search results view already existed for the current search on GitHub, and the functionality for most search types, except code, is the same. With GitHub Code Search beta enabled, the search results page has a redesigned UI and includes filters that are part of the new code search engine, such as path and symbol filters.
55+
56+
To construct a search query and view, sort, and filter results using a visual interface, you can use {% data variables.search.search_page_url %} or {% data variables.search.advanced_url %}.
57+
58+
If you hit Enter after typing a search query in the search bar, you will also be taken to the search results view.
59+
60+
On the search results view, you can navigate between different types of search results, including code, issues, pull request, repositories, and more. You can also view and click on filters and sort results.

content/search-github/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ featuredLinks:
1414
- /search-github/searching-on-github/searching-users
1515
- /search-github/searching-on-github/finding-files-on-github
1616
- /search-github/getting-started-with-searching-on-github/sorting-search-results
17+
- /search-github/github-code-search/about-github-code-search
1718
guideCards:
1819
- /search-github/searching-on-github/searching-in-forks
1920
- /search-github/searching-on-github/searching-topics
@@ -36,6 +37,7 @@ topics:
3637
children:
3738
- /getting-started-with-searching-on-github
3839
- /searching-on-github
40+
- /github-code-search
3941
shortTitle: Search on GitHub
4042
---
4143

content/search-github/searching-on-github/searching-code.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ versions:
1515
topics:
1616
- GitHub search
1717
---
18+
19+
{% ifversion github-code-search %}
20+
{% note %}
21+
22+
**Note:** {% data reusables.search.classic-search-code-search-note %}
23+
24+
{% endnote %}
25+
{% endif %}
26+
1827
{% data reusables.search.you-can-search-globally %} For more information, see "[About searching on GitHub](/search-github/getting-started-with-searching-on-github/about-searching-on-github)."
1928

2029
You can only search code using these code search qualifiers. Search qualifiers specifically for repositories, users, or commits, will not work when searching for code.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Reference: #6672
2+
# Documentation for GitHub Code Search limited public beta
3+
versions:
4+
fpt: '*'
5+
ghec: '*'

0 commit comments

Comments
 (0)