File search improvements in code aware search for Bitbucket Cloud

By on May 10, 2018

Last October, Bitbucket Cloud launched code aware search: a semantic search that ranks results by relevance, starting with the function or type definition first. It was built this way to save time manually combing through results when looking for things like classes, interfaces, structs or enums. We’ve continued to expand it by adding a code search API so developers can make code search work for their unique needs.

Since launch, code collaborators could efficiently find the code they were searching for, but results for a file search would show usages of the filename in the code and not the actual filename. This caused a lot of effort to find the file. To fix this, we’ve launched improved file search support which now includes filename matches, extending the syntax-aware code search.

What’s new with file searches? 

#1 Search results take into account filenames and paths

Files can now be found just by searching their filename or parts of the path.

file search bitbucket

If a search matches both in a file’s path and content, those results are shown first. We aim to match the developer’s search intent with smart ranking by boosting search results based on matches in the file’s name, path or code.

#2 A path modifier to refine results

A developer searching for a common phrase or name would get served overwhelming results that they would have to click through page after page to find the right result. To make this easier, a developer can now enter the path modifier, which can be used to limit the search to certain paths or exclude them.

A lot of people will have checked in node_modules and so it’s a very common match. The new path modifier supports a NOT option so the search could be updated to path:package.json -path:node_modules lodash to exclude those matches.

Bonus: A similar filter can be achieved using path anchoring, searching with path:/package.json lodash will only return results for package.json files at the root of the repository.

Try Bitbucket Cloud’s file search

If you’re ready to give our robust and relevant search a try, sign up for a Bitbucket Cloud account, create a repository, and add your code.

If you’re already a Bitbucket customer, you can find code search with improved file search from your sidebar and read further documentation on it here.