Commit 04e4338c authored by David Kim's avatar David Kim

Merge branch '301146-1s-server-side-timeouts-on-elasticsearch-counts' into 'master'

Set 1s server side timeout on Elasticsearch counts

See merge request gitlab-org/gitlab!53435
parents 4eded4bb a893b326
---
title: Set 1s server side timeout on Elasticsearch counts
merge_request: 53435
author:
type: performance
......@@ -10,6 +10,11 @@ module Elastic
def search(query, search_options = {})
es_options = routing_options(search_options)
# Counts need to be fast as we load one count per type of document
# on every page load. Fail early if they are slow since they don't
# need to be accurate.
es_options[:timeout] = '1s' if search_options[:count_only]
# Calling elasticsearch-ruby method
super(query, es_options)
end
......
......@@ -40,6 +40,7 @@ RSpec.shared_examples 'does not load results for count only queries' do |scopes|
expect(request.dig(:body, :size)).to eq(0)
expect(request.dig(:body, :query, :bool, :must)).to be_blank
expect(request[:highlight]).to be_blank
expect(request.dig(:params, :timeout)).to eq('1s')
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment