diff --git a/app/models/concerns/indexable.rb b/app/models/concerns/indexable.rb index 29b2b97b4..eadb1b2b3 100644 --- a/app/models/concerns/indexable.rb +++ b/app/models/concerns/indexable.rb @@ -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? diff --git a/app/models/doi.rb b/app/models/doi.rb index 8f5b35faa..b765cd512 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -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