Configure Bitbucket's code search index

このページの内容

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

This page describes how to configure what is indexed within the Bitbucket Server (or Data Center) code search index. This could be beneficial for your instance if you need to reduce the amount of disk space used by Elasticsearch, which provides the functionality for Bitbucket's code search.

There are various options you can use to optimize disk usage. Which configuration you choose depends on your needs, however organizations with a fork-based workflow are the most likely to see the benefits of changing code search index properties.


To change what is indexed for Bitbucket's code search

  1. Locate the bitbucket.properties file in the <Bitbucket home directory>/shared directory. 

  2. In the bitbucket.properties file, set a value for the property plugin.search.codesearch.indexing.exclude=

    These are the options for configuring what code is indexed. You can only set one value at a time.

    説明
    all-forksCode in forked repositories will not appear in code search results.
    personal-forksCode in forked repositories of personal projects will not appear in code search results.
    synced-forksCode in forked repositories with syncing enabled will not appear in code search results.
    undiverged-forksSame as synced-forks, except if the default branch is ever changed, the entire forked repository will be indexed
  3. Restart Bitbucket.

  4. If you've changed to a more restrictive setting (eg no exclusions, to forks exclusion) then you'll need to kick off a manual reindex. We will not automatically remove your data from the index, and only by running the search sync job will data be removed. Elasticsearch should be running when you execute this command. This will iterate through your repositories and remove all those from Elasticsearch where they would otherwise not be indexed with your new setting. In our example case this would mean all repositories that were forks would have their repository content removed from the Elasticsearch instance

    curl -XPOST -H 'Content-Type: application/json' -H 'Accept: application/json' -u <adminUsername> http://<BitbucketURL>/rest/indexing/latest/sync

Disable code search

You can also choose to disable code search entirely by changing the value of plugin.search.codesearch.indexing.enabled= to false. When code search is disabled, no repository content is indexed from the time at which the property is set. This does not disable Bitbucket's search box, or delete any existing indexes. Repository and project metadata will also still be indexed, allowing you to use the dashboard and search box's' repository quick search.

To remove the data from the index after disabling code search you must run the search sync job. Bitbucket will not remove data from the index until you specify you're ready via the following command.

curl -XPOST -H 'Content-Type: application/json' -H 'Accept: application/json' -u <adminUsername> http://<BitbucketURL>/rest/indexing/latest/sync

You still must have Elasticsearch to use Bitbucket Server


最終更新日: 2021 年 12 月 6 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.