Code search does not return all occurrences of a search term

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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

  • 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

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 - Getting issue details... STATUS

DescriptionCode search does not return all occurrences of a search term
ProductBitbucket
Last modified on Jun 29, 2020

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.