Bitbucket search syntax
This page explains Bitbucket Data Center's search syntax to help you find exactly what you're looking for.
Considerations
There are some restrictions on how searches are performed:
- Searches may include "." and "_", but all other punctuation characters are ignored. (e.g.
!"#$%&'()*+,-/:;<=>?@[\]^`{|}~
) - To search for multiple words in exact order, put them in quotes (e.g.
"find this phrase"
). As with other queries, all punctuation except "." and "_" is ignored (e.g."find-this-phrase"
effectively searches for"find this phrase"
). - Only the default branch is searchable (for most repositories the default branch will be
master
ormain
). - Wildcard searches (e.g.
qu?ck buil*
) and regular expressions in queries are not supported. - Single characters within search terms are ignored as they’re not indexed by Bitbucket for performance reasons (e.g. searching for “foo a bar” is the same as searching for just “foo bar” as the character “a” in the search is ignored).
- Case is not preserved, however search operators must be in ALL CAPS.
- Queries cannot have more than 9 expressions (e.g. combinations of terms and operators).
- The maximum length of a query cannot exceed 250 characters.
- Only files smaller than 512 KiB are searchable.
Only code you have permission to view will appear in the search results.
- Archived repositories are excluded from search results by default.
A query in Bitbucket has to contain at least one search term, which can either be a single word or a phrase surrounded by quotes.
演算子
Search operators are words that can be added to searches to help narrow down the results. Operators must be in ALL CAPS. These are the search operators that can be used to search for files:
AND
OR
NOT
-
( )
Multiple terms can be used, and they form a boolean query that implicitly uses the AND
operator. So a query for "bitbucket server
" is equivalent to "bitbucket AND server
".
用語 | クエリ例 | 用途 |
---|---|---|
AND | bitbucket AND server | Matches files that contain both "bitbucket " and "server ". |
OR | bitbucket OR server | Matches files that contain either "bitbucket " or "server " (or both). |
NOT | bitbucket NOT jira | Matches files that contain "bitbucket " but don't contain "jira ". |
- | bitbucket -jira | Use before a term, matches files that contain "bitbucket " but don't contain "jira ". |
( ) | bitbucket AND (server OR cloud) | Matches files that contain " |
Modifiers
Modifiers can be used to further restrict search results. Use a modifier in the form "key:value
". If there are multiple modifiers in a query they are implicitly combined using "AND
" and apply to the whole search expression. These are the search modifiers that can be used to search for files.
Repository and Project modifiers
repo: <reponame> or repository: <reponame>
Search within a particular repository. Must be used with a project:
modifier.
用語 | クエリ例 | 用途 |
---|---|---|
repo: |
または
または
| Matches files within the "bitbucket " repository within the "atlassian " project that contain the term "jira ". |
project: <project key/name>
Search all repositories within a particular project for the search term.
用語 | クエリ例 | 用途 |
---|---|---|
project: |
| Matches files within the "atlassian " project that contain the term "jira ". |
archived: <true/false/*>
Filter repositories based on their status.
用語 | クエリ例 | 用途 |
---|---|---|
archived: |
| Matches only repositories that are archived. |
archived:false | Matches only repositories that are active. Note that this filter is used by default. | |
archived:* | Matches all repositories (both archived and active) |
パス修飾子
path: <directory or file name>
Restrict search to only consider files with the search term in their path.
用語 | クエリ例 | 用途 |
---|---|---|
| react path:frontend | Matches files within directories named frontend containing the term react . |
react path:frontend/*/package.lock | Matches package.lock files within directories named frontend containing the term react . |
言語およびファイル拡張子の修飾子
lang: or language: <language>
Code search can be restricted to only consider a particular language or a particular file extension. For some languages adding a lang criteria is equivalent to specifying the file extension. For example, "lang:java
"
is equivalent to "ext:java
". For other languages multiple file extensions are mapped to a single language. For example, ".hs
", ".lhs
" and ".hs-bootare
" file extensions are used for the Haskell programming language, and will be matched when specifying "lang:haskell
".
用語 | クエリ例 | 用途 |
---|---|---|
lang: |
または
| Matches files that contain the term "jira " within Java files, files with .java , .class , or .jar extension. |
ext: or extension: <file extension>
用語 | クエリ例 | 用途 |
---|---|---|
ext: |
または
| Matches files that contain the term "jira " within Haskell files with the .lhs extension. |
Fork modifier
fork: <true or false>
Exclude results from repositories based on whether or not they are forks.
用語 | クエリ例 | 用途 |
---|---|---|
fork: | fork:true | Includes only results that are from repositories that are forks. |
fork:false | Includes only results that are from repositories that are not forks. |