Code search does not return all occurrences of a search term

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

When performing a search, some but not all occurrences of the search term are shown in the results.

This is usually observed in the following situations:

  • the file containing the search term is large

  • the occurrences of the term are not close to each other

Explanation

  • When a search is performed, up to 3 "fragments" of code will be returned for a given file that contains content that match the search query.

    The maximum number of fragments is set to 3 and is not configurable.

  • Each of these fragments can contain multiple occurrences of the search string

  • Each of these fragments is a chunk of up to 1400 characters

  • If there were more occurrences of the search term outside of these 3 fragments, they will not be returned as search matches.

Sample

(Auto-migrated image: description temporarily unavailable)
  • In this sample, a search for the term "gitactivity" was performed.

  • Two files were found containing the search string "gitactivity".

  • The first file shows 3 fragments showing multiple occurrences (21 matches) of the term.

    Other occurrences of the term outside of these 3 fragments are not shown.

  • The second file shows 1 fragment showing one match

Workaround

The search returns file(s) that contain at least one occurrence of the search term.

For situations that fall into the the scenario described in this KB (such as in the first file in the example), to find other occurrences of the search term:

  • Go into the file by clicking the link to the file name

  • Press the shortcut keys "CTRL + F" (or "CMD + F" for Mac)

  • Type in the search term in the "Find" search box

    (Auto-migrated image: description temporarily unavailable)

Reference

Please see the following link for other considerations related to code search:

Search for code in Bitbucket Server

New feature request

The following suggestion ticket was raised for this:

BSERV-12443 - Provide configuration options for the number of code fragments returned from a search

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.