Class IndexStatisticsService
java.lang.Object
io.goobi.viewer.model.statistics.index.IndexStatisticsService
Aggregations over the Solr index for index-level statistic charts. Constructor takes a
SolrSearchIndex
dependency so unit tests can mock it; production callers use the no-arg constructor that pulls the singleton.
Each method caches its result for one day and throws StatisticsUnavailableException when the upstream is
down and no cached snapshot is available, so the resource layer can translate to HTTP 503 instead of silently
returning empty data.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetImportSummary(String filter) Total page and full-text counts in the index.getImportTrend(int days, int dataPoints, String filter) Builds a cumulative-count time-series suitable for a line chart.getLanguages(Locale locale, String filter) Distribution of works by language with locale-translated display names.getPublicationCenturies(String filter) Histogram of works by publication century (e.g. century 18 = 1800–1899).getPublicationTypes(Locale locale, String filter) Lists each top-level docstruct type with its record count, with labels translated to the given locale.getTopCollections(int size, Locale locale, String filter) Topsizecollections by record count, with locale-translated labels.
-
Constructor Details
-
IndexStatisticsService
public IndexStatisticsService() -
IndexStatisticsService
-
-
Method Details
-
getPublicationTypes
public List<PublicationTypeStatistic> getPublicationTypes(Locale locale, String filter) throws StatisticsUnavailableException Lists each top-level docstruct type with its record count, with labels translated to the given locale.- Parameters:
locale- the user's locale for label translation; falls back to default if nullfilter- optional Lucene sub-query to constrain the docstructs; wrapped in MUST so it can only narrow. null or blank means no constraint.- Returns:
- DTOs in Solr's facet order (by count, descending), never null
- Throws:
StatisticsUnavailableException- if Solr is unreachable and no cached snapshot exists for this locale+filter
-
getImportTrend
public List<ImportTrendBucket> getImportTrend(int days, int dataPoints, String filter) throws StatisticsUnavailableException Builds a cumulative-count time-series suitable for a line chart.- Parameters:
days- size of the look-back windowdataPoints- number of buckets to produce; capped atdaysfilter- optional Lucene sub-query to constrain the time-series; wrapped in MUST so it can only narrow. null or blank means no constraint.- Returns:
- DTOs ordered newest first, never null
- Throws:
StatisticsUnavailableException- if Solr is unreachable and no compatible cached snapshot exists
-
getImportSummary
Total page and full-text counts in the index.- Parameters:
filter- optional Lucene sub-query to constrain both counts; wrapped in MUST so it can only narrow. null or blank means no constraint.- Returns:
- summary; both numbers populated from Solr or returned from cache on error
- Throws:
StatisticsUnavailableException- if Solr is unreachable and no cached snapshot exists
-
getPublicationCenturies
public List<PublicationCenturyStatistic> getPublicationCenturies(String filter) throws StatisticsUnavailableException Histogram of works by publication century (e.g. century 18 = 1800–1899). Pre-modern centuries are dropped.- Parameters:
filter- optional Lucene sub-query to constrain the histogram; wrapped in MUST so it can only narrow.- Returns:
- DTOs ordered chronologically (oldest century first), never null
- Throws:
StatisticsUnavailableException- if Solr is unreachable and no cached snapshot exists for this filter
-
getLanguages
public List<LanguageStatistic> getLanguages(Locale locale, String filter) throws StatisticsUnavailableException Distribution of works by language with locale-translated display names.- Parameters:
locale- the user's locale for label translation; falls back to default if nullfilter- optional Lucene sub-query to constrain the distribution; wrapped in MUST.- Returns:
- DTOs in Solr's facet order (by count, descending), never null
- Throws:
StatisticsUnavailableException- if Solr is unreachable and no cached snapshot exists
-
getTopCollections
public List<CollectionStatistic> getTopCollections(int size, Locale locale, String filter) throws StatisticsUnavailableException Topsizecollections by record count, with locale-translated labels.- Parameters:
size- maximum number of collections to returnlocale- the user's locale for label translation; falls back to default if nullfilter- optional Lucene sub-query to constrain the collections; wrapped in MUST.- Returns:
- DTOs in Solr's facet order (by count, descending), never null
- Throws:
StatisticsUnavailableException- if Solr is unreachable and no cached snapshot exists
-