Skip to content

Latest commit

 

History

History
108 lines (78 loc) · 8.61 KB

understanding-the-search-syntax.md

File metadata and controls

108 lines (78 loc) · 8.61 KB
title intro redirect_from versions topics shortTitle
Understanding the search syntax
When searching {% data variables.product.product_name %}, you can construct queries that match specific numbers and words.
/articles/search-syntax
/articles/understanding-the-search-syntax
/github/searching-for-information-on-github/understanding-the-search-syntax
/github/searching-for-information-on-github/getting-started-with-searching-on-github/understanding-the-search-syntax
fpt ghes ghec
*
*
*
GitHub search
Understand search syntax

{% ifversion code-search-upgrade %} {% note %}

Note: The syntax below applies to non-code search. For more information on code search syntax, see "AUTOTITLE."

{% endnote %} {% endif %}

Query for values greater or less than another value

You can use >, >=, <, and <= to search for values that are greater than, greater than or equal to, less than, and less than or equal to another value.

Query Example
>n cats stars:>1000 matches repositories with the word "cats" that have more than 1000 stars.
>=n cats topics:>=5 matches repositories with the word "cats" that have 5 or more topics.
<n cats size:<10000 matches code with the word "cats" in files that are smaller than 10 KB.
<=n cats stars:<=50 matches repositories with the word "cats" that have 50 or fewer stars.

You can also use range queries to search for values that are greater than or equal to, or less than or equal to, another value.

Query Example
n..* cats stars:10..* is equivalent to stars:>=10 and matches repositories with the word "cats" that have 10 or more stars.
*..n cats stars:*..10 is equivalent to stars:<=10 and matches repositories with the word "cats" that have 10 or fewer stars.

Query for values between a range

You can use the range syntax n..n to search for values within a range, where the first number N is the lowest value and the second is the highest value.

Query Example
n..n cats stars:10..50 matches repositories with the word "cats" that have between 10 and 50 stars.

Query for dates

You can search for dates that are earlier or later than another date, or that fall within a range of dates, by using >, >=, <, <=, and range queries. {% data reusables.time_date.date_format %}

Query Example
>YYYY-MM-DD cats created:>2016-04-29 matches issues with the word "cats" that were created after April 29, 2016.
>=YYYY-MM-DD cats created:>=2017-04-01 matches issues with the word "cats" that were created on or after April 1, 2017.
<YYYY-MM-DD cats pushed:<2012-07-05 matches repositories with the word "cats" that were pushed to before July 5, 2012.
<=YYYY-MM-DD cats created:<=2012-07-04 matches issues with the word "cats" that were created on or before July 4, 2012.
YYYY-MM-DD..YYYY-MM-DD cats pushed:2016-04-30..2016-07-04 matches repositories with the word "cats" that were pushed to between the end of April and July of 2016.
YYYY-MM-DD..* cats created:2012-04-30..* matches issues created after April 30th, 2012 containing the word "cats."
*..YYYY-MM-DD cats created:*..2012-07-04 matches issues created before July 4th, 2012 containing the word "cats."

{% data reusables.time_date.time_format %}

Query Example
YYYY-MM-DDTHH:MM:SS+00:00 cats created:2017-01-01T01:00:00+07:00..2017-03-01T15:30:15+07:00 matches issues created between January 1, 2017 at 1 a.m. with a UTC offset of 07:00 and March 1, 2017 at 3 p.m. with a UTC offset of 07:00.
YYYY-MM-DDTHH:MM:SSZ cats created:2016-03-21T14:11:00Z..2016-04-07T20:45:00Z matches issues created between March 21, 2016 at 2:11pm and April 7, 2016 at 8:45pm.

Exclude results that match a qualifier

You can narrow down search results by excluding one or more subsets. To exclude all results that are matched by a qualifier, prefix the search qualifier with a hyphen (-).

Query Example
-QUALIFIER cats stars:>10 -language:javascript matches repositories with the word "cats" that have more than 10 stars but are not written in JavaScript.
-QUALIFIER mentions:defunkt -org:github matches issues mentioning @defunkt that are not in repositories in the GitHub organization.

Exclude results with specific keywords

You can exclude results containing a certain word, using the NOT syntax. The NOT operator can only be used for string keywords. It does not work for numerals or dates.

Query Example
NOT hello NOT world matches repositories that have the word "hello" but not the word "world."

Use quotation marks for queries with whitespace

If your search query contains whitespace, you will need to surround it with quotation marks. For example:

{% ifversion ghes %} Some non-alphanumeric symbols, such as spaces, are dropped from code search queries within quotation marks, so results can be unexpected.{% endif %}

Queries with usernames

If your search query contains a qualifier that requires a username, such as user, actor, or assignee, you can use any {% data variables.product.product_name %} username, to specify a specific person, or @me, to specify the current user.

Query Example
QUALIFIER:USERNAME author:nat matches commits authored by @nat
QUALIFIER:@me is:issue assignee:@me matches issues assigned to the person viewing the results

You can only use @me with a qualifier and not as search term, such as @me main.workflow.