検索

To start searching in Bitbucket, click on the magnifying glass under the Bitbucket icon in the sidebar, then enter either a single word or an entire phrase (in double quotes). 

The keyboard shortcut to start a search from anywhere in Bitbucket is " / ".

Search results in Bitbucket are code aware, which means your search results are ranked so that function and type definitions will display before other results.

You can also use operators or modifiers to help you to refine search results.

Search scopes

The scope of a search changes according to where you are searching from:

Search context Search scope
An account All repositories owned or accessible to a user or team
リポジトリ An individual repository and its sub-directories

 

To search in public repositories that aren't associated to any accounts you have access to, go to that repository and search there.

Phrase queries

A phrase query can be used to find multiple words that appear in a specific order.

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 (or part of a word), your query would look like this. 

"abstract class"

This query would also find instances such as "abstract(class". 

 The same search query without the double quotes would return files that contain both abstract and class in any order.

We've simplified search

We've removed some operators to make it easier to search for the code you're looking for.

Search operators

Search operators can be used to refine your search results:

  • Operators must be in ALL CAPS.
  • Operators cannot be used alone; they must be used with an accompanying search term.
  • You cannot use AND in your search query; multiple search terms are implicitly combined. For example, a query for bitbucket jira means that only files that contain both bitbucket and cloud are matched. 

These are the search operators available: 

Operator
Example query
結果
なし bitbucket jira Returns files that contain the terms bitbucket and jira, in any order.
NOT bitbucket NOT jira Returns files that contain bitbucket but don't contain jira.
- bitbucket -jira Used before a term; returns files that contain bitbucket but don't contain jira.

 

Examples of valid ((tick)) and invalid ((error)) search syntax:

有効性 クエリ 結果
(error)
MyClass AND MyComponent NOT "YourClass"
AND is not valid syntax; search terms are implicitly combined.
(error) NOT "YourClass"
Operators cannot be used alone; you must specify a search term to match before what to exclude.
(tick) MyClass MyComponent NOT "YourClass" Finds files that contain the terms MyClass and MyComponent but does not contain YourClass

Search modifiers

Modifiers can be used to refine search results:

  • Use a modifier in the form key:value
  • You can combine multiple modifiers – see the section Use multiple modifiers below.

These are the search modifiers available:

Modifier
Example query
結果
ext:<file extension> <term> 
ext:lhs jira

Matches Haskell files with the .lhs extension that contain the term jira.

lang:<language> <term>
lang:c jira

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

project:<project key> <term>
project:MYPROJ jira
Matches files in the project with key MYPROJ that contain the term jira.
repo:<repo slug> <term>  repo:myrepo myClass

Matches files in myrepo that contain the term myClass.

Wildcards are not supported in repo names.

Only the default branch of the repo is searched.

 

Language and file extension modifiers

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:java is equivalent to ext:java. For other languages, multiple file extensions are mapped to a single language. For example, the .hs.lhs and .hs-boot file extensions are used for the Haskell programming language, and will be matched when specifying lang:haskell.

Note that 'language' as used here is not related to the Language setting for a repository.

Click here to see all 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 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 velocity xml yaml

Use multiple modifiers

You can't need to use an operator with modifiers because modifiers are implicitly combined depending on their type. When using multiple search modifiers in your search query:

  • Search modifiers of the same kind are implicitly combined using the AND operator
  • Search modifiers of different kinds are implicitly combined using the OR operator. 
  • Search modifiers apply to the entire search expression.

For example, here is a query that would find files with either the .js or the .jsx extension, that are in either repo A or repo B, and that contain the phrase "search-term".

repo:A repo:B ext:js ext:jsx search-term

 

Examples of valid ((tick)) and invalid ((error)) search syntax:

有効性 クエリ 結果
(tick) ext:js project:myProject MyComponent Finds files with the js extension that are in the myProject project that contain the term MyComponent.
(error) ext:js NOT project:myProject MyComponent You cannot combine search modifiers with search operators.
(tick) ext:js ext:java MyComponent
Finds files with the js OR java extension that contains the term MyComponent.

Code search considerations

There are some things to consider regarding how searches are performed:

  • Search uses the default branch in a repo (usually the default branch will be master).
  • We index files smaller than 320 KB – you won't see search results from larger files.
  • Wildcard searches (e.g. qu?ck buil*) are not supported.
  • We strip the following characters from search terms: !"#$%&'()*+,/;:<=>?@[\]^`{|}~-
  • Regular expressions are not supported in queries, but you can search for special characters.
  • Case is not preserved (but search operators must be in ALL CAPS).
  • Queries can have up to 9 expressions (i.e. combinations of terms and operators).
  • Queries can be up to 250 characters in length.
  • We make sure that you only see the code you have permission to view in search results.

最終更新日: 2017 年 12 月 7 日

この翻訳に満足しましたか?

はい
いいえ
この記事についてのフィードバックを送信する

お探しの情報が見つかりませんか?

コミュニティへの質問

Powered by Confluence and Scroll Viewport.