Skip to content

Commit

Permalink
limit the size of agg
Browse files Browse the repository at this point in the history
  • Loading branch information
kjgarza committed Mar 19, 2019
1 parent 0f3c9c9 commit 76407c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ def recreate_index(options={})
client.indices.create index: index_name, body: { settings: {"index.requests.cache.enable": true }}
end

def count
Elasticsearch::Model.client.count(index: index_name)['count']
end

def create_alias(index: nil)
return nil unless index.present?

Expand Down
6 changes: 3 additions & 3 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ def self.query_aggregations

def self.totals_aggregations
{
providers_totals: { terms: { field: 'provider_id', size: 200, min_doc_count: 1 }, aggs: sub_aggregations},
clients_totals: { terms: { field: 'client_id', size: 2000, min_doc_count: 1 }, aggs: sub_aggregations },
prefixes_totals: { terms: { field: 'prefix', size: 2000, min_doc_count: 1 }, aggs: sub_aggregations },
providers_totals: { terms: { field: 'provider_id', size: ::Provider.count, min_doc_count: 1 }, aggs: sub_aggregations},
clients_totals: { terms: { field: 'client_id', size: ::Client.count, min_doc_count: 1 }, aggs: sub_aggregations },
prefixes_totals: { terms: { field: 'prefix', size: ::Prefix.count, min_doc_count: 1 }, aggs: sub_aggregations },
}
end

Expand Down

0 comments on commit 76407c0

Please sign in to comment.