📜 ⬆️ ⬇️

Search code in Bitbucket Server

I am pleased to share the news, which I hope will please some Habr's readers: in Bitbucket Server , the ability to search by code is about to appear. Just the other day, the release of the Early Access Program (EAP) was released.

I’ll start with a free translation of the appeal from a product manager published on the Atlassian blog :


How often this happened to you: you see an error message, but you do not know in which part of the code it occurs, or you know the name of the function, but not the repository, in the code of which it is defined. Many of you have asked for a code search in Bitbucket Server, and I am pleased to announce that your wait has come to an end. Today, we invite our users to try out the code search in Bitbucket Server through the Early Access Program (EAP). Now you can search and find the necessary code using the search string:

Search line

')

How it works?



We understand that many teams have a huge amount of code. Therefore, we made it so that you can easily limit search results to a specific project or repository using search filters. In addition, you can search for the code in a given language (for example, lang:java ) or in files with a specific extension (for example, ext:css ).

Search filters

The operators AND , OR and NOT will help to refine the query, they are useful for further filtering the search results in the case when there are too many of them.

Logical operators

What to do to start using?



Glad you asked! Here you can download the Bitbucket Server EAP distribution with support for code search, and step-by-step instructions prepared by us should help with launching and configuring. We would be grateful if you tell us about your impressions of the EAP distribution, your feedback is extremely important to us. By filling out this short and simple questionnaire , you will help us improve the search for you and other Bitbucket users for its official release.

We are working to bring you more opportunities soon. Have a good search!

Steve king

TL; DR


In a brief retelling, the installation instructions boil down to the following steps:


  1. Install Git and Perl (for installing Git here )
  2. Download the desired distribution from the EAP page
  3. Start the installer (if you use the ZIP distribution, before starting Bitbucket Server you will have to perform a few more preliminary steps )
  4. Complete the installation procedure and wait for the Bitbucket Server launch.
  5. ???
  6. PROFIT !!!

How does the search work?


As you can see from the help pages and the contents of the distribution, Elasticsearch is used to store the index with which the search is performed . It, in turn, is based on the well-known Apache Lucene library.


Elasticsearch

In Bitbucket Server, search provides two modules: the first is engaged in indexing repositories, the second serves search queries from users. Indexing takes place constantly in the background. If you update Bitbucket Server, which already contains a number of repositories, the initial indexing may take some time, but as soon as it is completed, subsequent changes are processed very quickly. It is worth noting that the search is available immediately, but as long as the indexing is in progress, its results may be incomplete. In addition, in order to optimize performance, a small delay was introduced between the moment of repository change (for example, a new code commit) and the moment when this change is reflected in the search results. By default, this delay can reach 15 seconds.

The installation procedure, compared with previous versions of Bitbucket Server, has not changed: all configuration actions necessary for the search operation are performed automatically. At the same time, it is not necessary to use the built-in copy of Elasticsearch: if you wish, you can customize the desired configuration yourself.




What exactly can I look for?


The search has several limitations:



The search query must contain at least one term, which can be a word or a quotation phrase.



Operators


Operators can be added to the query to refine the search. Here is their current list:


OperatorRequest exampleValue
ANDbitbucket AND serverCorresponds to files containing both the words "bitbucket" and "server"
ORbitbucket OR serverCorresponds to files containing at least one of the words "bitbucket" or "server"
NOTbitbucket NOT jiraCorresponds to files containing the word "bitbucket", but not containing the word "jira"
-bitbucket -jiraUsed before term; matches files containing the word "bitbucket" but not containing the word "jira"
( )bitbucket AND (server OR cloud)Corresponds to files containing the word "bitbucket" and any of the words "server" or "cloud"

A query can contain several terms, and by default, they are implicitly combined using the logical AND operator. That is, a bitbucket server request is equivalent to a bitbucket AND server request.



Modifiers


Modifiers help limit your search. They are written in the : format. If the query contains several modifiers, they are implicitly combined with the AND operator and are applied to the entire expression. The following modifiers are currently supported:



File extension and language modifiers


Search may be limited to languages ​​and file extensions. For some languages, these two criteria are identical: for example, the lang:clojure and ext:clj will ext:clj the same result. However, there are some languages ​​to which several file extensions correspond: for example, the .hs and .lhs are used in Haskell, and files with any of these extensions will be included in the search results with the lang:haskell modifier.





Just in case, I note that the instructions on the following help pages will be finalized in the near future to make the installation, configuration, and use of Bitbucket Server search even better. Let me remind you that your comments on any aspects of using EAP release are warmly welcome .



For me, this news is especially pleasant and important because I am directly involved in the development of search. I will be glad to answer any questions and comments.

Source: https://habr.com/ru/post/280133/


All Articles