2021-11-12 10:13:22 +01:00
|
|
|
import { Dataset } from "./dataset";
|
|
|
|
|
|
|
|
export interface SolrResponse {
|
|
|
|
responseHeader: ResponseHeader;
|
|
|
|
response: ResponseContent;
|
|
|
|
facets: FacetFields;
|
|
|
|
// facet_counts: FacetCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ResponseHeader {
|
|
|
|
status: boolean;
|
|
|
|
QTime: number;
|
|
|
|
params: ResponseHeaderParams;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ResponseHeaderParams {
|
|
|
|
defType: string;
|
|
|
|
rows?: number;
|
|
|
|
start?: number;
|
|
|
|
wt?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ResponseContent {
|
|
|
|
numFound: number;
|
|
|
|
start: number;
|
|
|
|
docs: Array<Dataset>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class FacetResults {
|
2021-11-19 16:11:26 +01:00
|
|
|
[key: string]: Array<FacetItem>;
|
2021-11-12 10:13:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export class FacetFields {
|
|
|
|
language!: FacetInstance;
|
|
|
|
subject!: FacetInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface FacetInstance {
|
|
|
|
[key: string]: Array<FacetItem>;
|
|
|
|
}
|
|
|
|
|
2021-11-12 15:49:27 +01:00
|
|
|
export class FacetItem {
|
2021-11-12 10:13:22 +01:00
|
|
|
val: string;
|
|
|
|
count: number;
|
|
|
|
category: string;
|
|
|
|
active: boolean;
|
2021-11-12 15:49:27 +01:00
|
|
|
|
|
|
|
constructor(value: string, count: number) {
|
|
|
|
this.val = value;
|
|
|
|
this.count = count;
|
|
|
|
this.active = false;
|
|
|
|
this.category = "";
|
|
|
|
}
|
2021-11-12 10:13:22 +01:00
|
|
|
}
|
2021-11-19 16:11:26 +01:00
|
|
|
//#endregion
|
2024-06-06 17:11:54 +02:00
|
|
|
|
|
|
|
// OPENSEARCH
|
|
|
|
// ========================================================================
|
|
|
|
export interface OpenSearchResponse {
|
|
|
|
took: number;
|
|
|
|
timed_out: boolean;
|
|
|
|
_shards: Shards;
|
2024-06-12 16:51:26 +02:00
|
|
|
hits: Hits; // Equivalent SOLR: response > docs
|
|
|
|
aggregations?: Aggregations; // Equivalent SOLR: facets
|
2024-06-06 17:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface Shards {
|
|
|
|
total: number;
|
|
|
|
successful: number;
|
|
|
|
skipped: number;
|
|
|
|
failed: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Hits {
|
|
|
|
total: Total;
|
|
|
|
max_score: number;
|
|
|
|
hits: Array<Hit>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Total {
|
2024-06-12 16:51:26 +02:00
|
|
|
value: number; // Equivalent SOLR: response > numFound
|
2024-06-06 17:11:54 +02:00
|
|
|
relation: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Hit {
|
|
|
|
_index: string;
|
|
|
|
_id: string;
|
|
|
|
_score: number;
|
|
|
|
_source: Dataset;
|
2024-06-11 09:33:03 +02:00
|
|
|
highlight: HitHighlight; // !! This name is to avoid collision with Typescript "Highlight" class
|
2024-06-07 17:44:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface HitHighlight {
|
|
|
|
subjects?: Array<string>;
|
|
|
|
title?: Array<string>;
|
|
|
|
author?: Array<string>;
|
2024-06-06 17:11:54 +02:00
|
|
|
}
|
|
|
|
|
2024-06-12 16:51:26 +02:00
|
|
|
export interface Aggregations { // Equivalent SOLR: FacetFields
|
2024-06-07 17:44:13 +02:00
|
|
|
subjects: Subjects;
|
|
|
|
language: Language;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Subjects {
|
|
|
|
doc_count_error_upper_bound: number;
|
|
|
|
sum_other_doc_count: number;
|
|
|
|
buckets: Array<Bucket>;
|
2024-06-06 17:11:54 +02:00
|
|
|
}
|
|
|
|
|
2024-06-07 17:44:13 +02:00
|
|
|
export interface Language {
|
|
|
|
doc_count_error_upper_bound: number;
|
|
|
|
sum_other_doc_count: number;
|
2024-06-06 17:11:54 +02:00
|
|
|
buckets: Array<Bucket>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Bucket {
|
|
|
|
key: string;
|
|
|
|
doc_count: number;
|
|
|
|
}
|
2024-06-07 17:44:13 +02:00
|
|
|
// // Needed?
|
|
|
|
// export interface Aggregations {
|
|
|
|
// [key: string]: Aggregation;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// export interface Aggregation {
|
|
|
|
// buckets: Array<Bucket>;
|
|
|
|
// }
|
|
|
|
|
|
|
|
|