Bitbucket Cloud での検索

To start searching in Bitbucket, select the search field in the top navigation bar. The keyboard shortcut to start a search from anywhere in Bitbucket is "/".

Search results in Bitbucket are code first and you can also use operators or modifiers to help you to refine search results. While you are searching, notice that you are provided with ways to refine your search, a list of recent searches, and a list of repositories that you may be searching for.

検索範囲

検索範囲は、検索場所によって変わります。

Search context/location

検索範囲

ワークスペース

All repositories in a workspace accessible to a user

リポジトリ

個別のリポジトリおよびそれらのサブディレクトリ

To search for code within a specific repository, go to the repository, select the dropdown in the search field (it is set to Files by default), and then select Code from the dropdown menu.

フレーズ クエリ

フレーズ クエリを使用すると、特定の組み合わせで表示される複数の単語を検索できます。

To search for a phrase, enclose the words in double quotes. For example, to find files with instances of the word abstract followed by the word class, your query would look like this.

"abstract class"

The same search query without the double quotes would return files that contain both abstract and class in any order. For example, a query for abstract class means that only files that contain both abstract and class are matched.

検索修飾子

修飾子を指定すると、検索結果を絞り込むことができます。

  • Use a modifier in the form key:value.

  • The modifier field name is case-sensitive, REPO:myrepo will throw an error.

  • You can combine multiple modifiers; they are combined with AND by default.

次の検索修飾子を利用できます。

修飾子

クエリ例

結果

repo:<repo slug> <term>

Note: You can also use repository: in place of repo:.

repo:myrepo MyClass

 

Matches files in myrepo that contain the term MyClass

  • Wildcards are supported in repository modifiers (see below).

  • リポジトリの既定のブランチのみが検索されます。

path:<directory|path segment|filename(with extension)> <term>

path:src MyClass

パスが src と一致し、MyClass という単語を含むファイル

  • Wildcards are supported in path modifiers (see below)

extension:<file extension> <term>

extension:go jira

Note: do not include the dot delimiter, i.e. extension:.go will not return results.

Matches files with the .go extension that contain the term jira

lang:<language> <term>

Note: You can also use language: in place of lang:

lang:c jira

Matches C files with the .c or .h extensions that contain the term jira

forks:true <term>

Note: forks:true is a top level modifier. It cannot be grouped with other modifiers using and / or or negated using not / -.

forks:true jira

Note: the forks: modifier only accepts the value true.

Matches files from repository forks that contain the term jira.

  • Forks are excluded without this flag.

Project-level search coming back soon

We are working on implementing the project-level search modifiers that previously existed into the new search experience. Thanks for your patience.

パス修飾子

Code search can be restricted to only consider a particular path. For the purpose of search, file paths are split up into segments (parts separated by /) including directories and filenames. Matching is done on one or more segment and is case-insensitive.

There is no partial matching within a segment. This means path:mai will not match a file at src/main/java/Foo.java because the indexed term is main, not mai. Specifically for file names, path:foo will not match src/foo.java — the full filename including extension must be specified, e.g. path:foo.java.

クエリ例

結果

path:src MyClass

Files with paths containing the segment src which contain the term MyClass

path:src/main MyClass

Files with paths containing the consecutive segments src/main which contain the term MyClass

MyClass NOT path:src

Files which contain the term MyClass with paths that do not contain the segment src

Wildcards for path and repository modifiers

The path: and repo: modifiers support the * and ? wildcards. When a wildcard is used, the pattern is matched against the full file path or repository slug as a single string, not against individual segments of the path or repository slug. * matches any sequence of characters including path separators, and ? matches exactly one character. Wildcard matching is case-sensitive.

クエリ例

結果

path:*/src/*/module/* MyClass

Files inside a module/ directory under any subdirectory of src/, which contain the term MyClass.

path:*/styles/*.css class

Files inside a styles/ directory with a .css extension that contain the term class.

path:*/index.?s export

Files named index.js or index.ts preceded by any other path segments that contain the term export

path:index.?s export

Files named index.js or index.ts where index.?s matches the entire path and contains the term export

path:*/v?/* api

Files in a single-character versioned directory such as v1/ or v2/ that contain the term api

repo:mobile-* login

Files containing login in any repository whose name starts with mobile-, such as mobile-ios and mobile-android

repo:*-service login

Files containing login in any repository whose name ends with -service

repo:*payment* login

Files containing login in any repository with payment anywhere in its name

repository:my-repo? login

Files containing login in any repository that starts with my-repo followed by exactly one character, like my-repo1, my-repoX

repo:payment login

Only the repository named exactly payment. Without a wildcard, the name must match in full — this won't match payment-service.

言語およびファイル拡張子の修飾子

Code search can be restricted to only consider a particular language or a particular file extension. For some languages, adding a language criteria is equivalent to specifying the file extension. For example, lang:go is equivalent to extension:go. For other languages, multiple file extensions are mapped to a single language. For example, the .hs and .lhs file extensions are used for the Haskell programming language, and will be matched when specifying lang:haskell.

ここで使用する 'language' は、リポジトリの言語設定には関係しません。

These are the languages recognized by code search:

ada, asp.net, assembly, c, c++, c#, clojure, cobol, cql, css, cython, fortran, go, groovy, haskell, html, java, javascript, js, json, kotlin, latex, less, lisp, markdown, mathematica, matlab, objective-c, ocaml, pascal, perl, php, plain, plsql, properties, python, r, ruby, rust, sas, scala, scss, shell, sieve, soy, sql, swift, typescript, ts, velocity, xml, yaml

検索演算子

Search operators can be used with modifiers to refine your search results.

  • Operators cannot be used alone or with search terms; they can only be used with modifiers.

  • See more on using multiple modifiers in the next section.

These are the search operators available:

演算子

クエリ例

結果

AND または and

bitbucket repo:jira AND lang:go

Returns files from the jira repository, written in go, that contain the term bitbucket

OR または or

bitbucket repo:jira or repo:confluence

Returns files from the jira repository or the confluence repository that contain the term bitbucket

NOT または not

bitbucket NOT repo:jira

Returns files that contain bitbucket but exclude results from the jira repository

-

bitbucket -repo:jira

Shorthand for NOT; returns files that contain bitbucket but exclude results from the jira repository

Examples of valid and invalid search syntax

Validity

クエリ

結果

Not valid

MyClass OR MyComponent AND "YourClass"

Operators, such as OR and AND, cannot be used between search terms.

Not valid

NOT MyClass

Operators, such as NOT, cannot be used with search terms. NOT can only be used to negate modifiers.

有効性

MyClass MyComponent NOT repo:jira

Finds files that contain the terms MyClass and MyComponent, excluding results from the jira repository.

有効性

MyClass (repo:jira or repo:confluence) extension:go

Finds files with the .go extension containing MyClass in either the jira or confluence repository.

複数の修飾子を使用する

It’s not required to use an operator between modifiers: modifiers are implicitly combined with the AND operator. However, especially when using two modifiers of the same type, you may want to specify an operator like or between them.

For example, here is a query that would find files that 1) are from either repo:A or repo:B 2) have the .js extension 3) have test as part of their file path and 4) that contain the term search-term.

repo:A or repo:B extension:js path:test search-term

Note: The example uses the or operator between repo:A and repo:B. Because all modifiers are combined with and by default, the query repo:A repo:B search-term would search for files that are simultaneously in repo A and repo B (which is not possible) and return no results.

Examples of valid and invalid search syntax:

Validity

クエリ

結果

有効性

extension:js repo:myRepo MyComponent

Finds files with the js extension that are in the myRepo repository that contain the term MyComponent

有効性

MyClass NOT repo:test

MyClass という単語を含むすべてのファイル (test リポジトリを除く) を検索します

有効性

MyClass -extension:java

MyClass という単語を含むすべてのファイル (java ファイルを除く) を検索します

有効性

extension:js AND repo:myRepo MyComponent

AND can be used to explicitly combine modifiers

有効性

extension:js NOT repo:myProject MyComponent

js 拡張子を持ち、myProject 以外の任意のプロジェクトに含まれ、MyComponent という単語を含むファイルを検索します。

Not valid

extension:js extension:java MyComponent

Looks for files with both the js AND java extensions that contain the term MyComponent and yields no results.

Operator precedence and grouping

When you use OR between two modifiers, it applies only to those two modifiers. The implicit AND still joins that pair to the rest of your query. So this query finds files in either the jira or confluence repository that are written in Go:

bitbucket repo:jira or repo:confluence lang:go

To combine more than one or, or to make the grouping explicit, use parentheses.

This query finds files with either the .js or .jsx extension, in either the jira or confluence repository, that contain MyComponent:

MyComponent (repo:jira or repo:confluence) (extension:js or extension:jsx)

NOT and - negate the modifier or parenthesized group that immediately follows.

This query will exclude several repositories at once:

MyClass -(repo:jira or repo:confluence)

Examples of valid and invalid usage of parentheses:

Validity

クエリ

結果

有効性

MyComponent (repo:jira or repo:confluence)

Finds files that are in the jira or confluence repositories that contain the term MyComponent

有効性

MyComponent (repo:jira and extension:go)

Finds files with the go extension that are in the jira repository that contain the term MyComponent

有効性

MyClass -(repo:jira or repo:confluence)

Note: This is equivalent to writing MyClass -repo:jira -repo:confluence.

Finds files that are not in the jira or confluence repositories that contain the term MyClass

⚠️ Valid, but not effective

MyClass -(repo:jira and repo:confluence)

Excludes only files that are in both jira and confluence repositories simultaneously, which isn't possible. As a result, nothing is excluded. Use or to exclude both

Not valid

(repo:jira repo:confluence)

Note: Inside parentheses you must use an explicit operator.

Invalid syntax error

コード検索の考慮事項

検索の実行方法については、いくつかの考慮事項があります。

  • Search uses the default branch in a repository.

  • We index files smaller than 512 KB – you won't see search results from larger files.

  • Wildcard matching in search terms (e.g. qu?ck buil*) is not supported.

  • 正規表現はクエリではサポートされません。

  • Case is not preserved, except in wildcard patterns for path: and repo: modifiers.

  • There is no strict query length limit, though very long queries may result in degraded performance.

  • 検索結果には、閲覧権限を持つコードのみが表示されます。

Search for files

Files can be found by searching their filename or a folder name from its path. See the examples in the table below.

クエリ

結果

package.json

package.json という名前のファイルを見つける

package lock json

packagelock、および json を含むファイルを見つける (package-lock.json など)

Note: This type of query will also return code results containing the same keywords.

package.json path:test

test を含むパスを持つ、package.json という名前のファイルを見つける

MyClass

Finds files named MyClass.java and MyClassTest.java

 

さらにヘルプが必要ですか?

アトラシアン コミュニティをご利用ください。