BitBucket Code Aware Search

Dima Pursanov
3 min readSep 7, 2017

--

Today had to find some aspects from the code, but didn’t really remember the right repository, where the sample was.. We use BitBucket for code storage and suddenly I’ve found that they have a nice feature in their cloud interface: you can fast search for any text across all your repositories.

But the main feature here is that the search is not just simple INDEX, they added priorities to some terms so that you get more relevant results for the language you have used in that project.

Example:

For the term “hash” it shows:

And only after that things like:

Sure the more relevant is Class/Method definition in case of C# then some usage example.

How code search works in BitBucket Cloud

Search indices built using traditional text indexers will usually return the usage result first because it contains a higher number of exact matches for your search term. In code bases where the same class or function is used many times, developers are often left trawling through page after page of usage results trying to hunt down the definition.

We took a different approach: by boosting the definitions matching your search term, the result you want is likely to rank much higher (usually #1) in the search results. Our algorithm boosts definitions for a wide range of type categories including classes, functions, enums, structs, and interfaces. We prioritized building a code aware search scoped to team and user accounts over a global search functionality. This way, we hope to quickly give our users the relevant results they want instead of the hassle of checking out a repo locally and searching using an IDE.

Go, with the Flow

In case you are paranoidal about security you will find such an interesting record in your Audit Logs:

Some guy, who installed the addon in my profile!

Sure there is no problem in removing the addon from settings:

More in their official blog.

--

--

No responses yet