How to increase Pagination in Elasticsearch since every search is limited to 1000 results

お困りですか?

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

コミュニティに質問


プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

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.

*Fisheye および Crucible は除く




目的

In this article we will go through the steps to increase the max_result_window of Elasticsearch.

問題

  • When searching a word which happens to present in more than 1000 files in all of Bitbucket repositories, results can be seen for only the first 1000. Subsequent results are not fetched and we are instead presented with the following alert:

  • Clicking on the "Try again" button does not help and clicking on close will present a new error at the bottom of the page:

  • The following appears in the bitbucket_search.log
[2018-12-11 12:53:43,310][DEBUG][action.search] [bitbucket_bundled] [bitbucket-search-v1][4], node[L8MlmuIgS_6ZQaT34fxrQg], [P], v[2], s[STARTED], a[id=vGhgCsYaSe-eROu1iuuqoQ]: Failed to execute [org.elasticsearch.action.search.SearchRequest@7f46c5bd] lastShard [true]
RemoteTransportException[[bitbucket_bundled][local[1]][indices:data/read/search[phase/query]]]; nested: QueryPhaseExecutionException[Result window is too large, from + size must be less than or equal to: [1000] but was [1010]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level parameter.];
Caused by: QueryPhaseExecutionException[Result window is too large, from + size must be less than or equal to: [1000] but was [1010]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level parameter.]

原因

This is because of the Pagination settings which has set the max_result_window to only 1000 results. Read more about this in their official documentation.

回避策

  • We can update the max_result_window to a number high enough to accommodate the search results.
  • Atlassian does not support manipulation of Elasticsearch directly. Therefore please perform this on a test instance first.
  • Increasing to index.max_result_window value to a higher number may impact the performance of the system.
Increase max_result_window to 2000
curl -u bitbucket -X PUT "<SEARCH_SERVER_URL>/bitbucket-search/_settings" -d '{ "index" : { "max_result_window" : 2000 } }'


  • You will need to enter the bitbucket user's password.
    • For bundled Elasticsearch instances, this is located in: $BITBUCKET_HOME/search/buckler/buckler.yml file.
    • For remote Elasticsearch instances, this is located in: <Elasticsearch config>/buckler/buckler.yml.
      See Install and configure a remote Elasticsearch server for further details.
  • If the value is updated you should see the following response:
Enter host password for user 'bitbucket':
{"acknowledged":true}
説明 Increase pagination of Elasticsearch
製品Bitbucket server, Elasticsearch

最終更新日: 2023 年 12 月 4 日

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

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