diff --git a/src/components/active-facet-category/ActiveFacetCategory.ts b/src/components/active-facet-category/ActiveFacetCategory.ts index 4f6e6e8..e349444 100644 --- a/src/components/active-facet-category/ActiveFacetCategory.ts +++ b/src/components/active-facet-category/ActiveFacetCategory.ts @@ -34,6 +34,8 @@ export default class ActiveFacetCategory extends Vue { return "creator"; case "subjects": return "keyword"; + case "doctype": + return "datatype"; default: return this.categoryName; } diff --git a/src/components/face-category/FacetCategory.ts b/src/components/face-category/FacetCategory.ts index 3f1f8d0..4729410 100644 --- a/src/components/face-category/FacetCategory.ts +++ b/src/components/face-category/FacetCategory.ts @@ -33,6 +33,8 @@ export default class FacetCategory extends Vue { return "creator"; case "subjects": return "keyword"; + case "doctype": + return "datatype"; default: return this.filterName; } diff --git a/src/components/vs-input/vs-input.ts b/src/components/vs-input/vs-input.ts index 468d55b..d815ee9 100644 --- a/src/components/vs-input/vs-input.ts +++ b/src/components/vs-input/vs-input.ts @@ -140,6 +140,17 @@ export default class VsInput extends Vue { } } + // To allow search by doctype + if (highlight.doctype && highlight.doctype.length > 0) { + const highlightedDoctype = highlight.doctype.join(" "); + + const hasDoctypeSuggestion = suggestions.some((suggestion) => suggestion.highlight.toLowerCase() === highlightedDoctype.toLowerCase() && suggestion.type == SearchType.Doctype); + if (!hasDoctypeSuggestion) { + const suggestion = new Suggestion(dataset.doctype, highlightedDoctype, SearchType.Doctype); + suggestions.push(suggestion); + } + } + // ORIGINAL SOLR =================================================================================================== // if (dataset.title_output.toLowerCase().includes(this.display.toLowerCase())) { // const title = dataset.title_output; diff --git a/src/models/dataset.ts b/src/models/dataset.ts index 2c141d4..16e5271 100644 --- a/src/models/dataset.ts +++ b/src/models/dataset.ts @@ -82,7 +82,8 @@ export class Suggestion { export enum SearchType { Title = "title", Author = "author", - Subject = "subjects" // ** !! The field has this name in OpenSearch!! + Subject = "subjects", // ** !! The field has this name in OpenSearch!! + Doctype = "doctype" } export class DbDataset { diff --git a/src/models/headers.ts b/src/models/headers.ts index 87e370b..82c5423 100644 --- a/src/models/headers.ts +++ b/src/models/headers.ts @@ -96,11 +96,13 @@ export interface HitHighlight { subjects?: Array; title?: Array; author?: Array; + doctype?: Array; } export interface Aggregations { // Equivalent SOLR: FacetFields subjects: Subjects; - language: Language; + language: Language; + doctype: Doctype; } export interface Subjects { @@ -115,6 +117,12 @@ export interface Language { buckets: Array; } +export interface Doctype { + doc_count_error_upper_bound: number; + sum_other_doc_count: number; + buckets: Array; +} + export interface Bucket { key: string; doc_count: number; diff --git a/src/services/dataset.service.ts b/src/services/dataset.service.ts index fb1cd34..7e4d688 100644 --- a/src/services/dataset.service.ts +++ b/src/services/dataset.service.ts @@ -42,9 +42,11 @@ class DatasetService { { match: { title: { query: term, fuzziness: "AUTO", boost: 3 } } }, { match: { author: { query: term, fuzziness: "AUTO", boost: 2 } } }, { match: { subjects: { query: term, fuzziness: "AUTO", boost: 1 } } }, // In SOLR is "subject"! + { match: { doctype: { query: term, fuzziness: "AUTO", boost: 1 } } }, // doctype { wildcard: { title: { value: `${lowercaseTerm}*`, boost: 3 } } }, { wildcard: { author: { value: `${lowercaseTerm}*`, boost: 2 } } }, - { wildcard: { subjects: { value: `${lowercaseTerm}*`, boost: 1 } } } // In SOLR is "subject"! + { wildcard: { subjects: { value: `${lowercaseTerm}*`, boost: 1 } } }, // In SOLR is "subject"! + { wildcard: { doctype: { value: `${lowercaseTerm}*`, boost: 1 } } } // doctype ], minimum_should_match: 1 } @@ -58,7 +60,8 @@ class DatasetService { subjects: { terms: { field: "subjects.keyword", size: 1000 } }, // In SOLR is "subject"! language: { terms: { field: "language" } }, // << ".keyword" HAS TO BE REMOVED. OTHERWISE BUCKETS ARE NOT OBTAINED FOR THIS author: { terms: { field: "author.keyword", size: 1000 } }, - year: { terms: { field: "year", size: 100 } } // << ".keyword" HAS TO BE REMOVED. OTHERWISE BUCKETS ARE NOT OBTAINED FOR THIS + year: { terms: { field: "year", size: 100 } }, // << ".keyword" HAS TO BE REMOVED. OTHERWISE BUCKETS ARE NOT OBTAINED FOR THIS + doctype: { terms: { field: "doctype", size: 50 } } // << ".keyword" HAS TO BE REMOVED. OTHERWISE BUCKETS ARE NOT OBTAINED FOR THIS }, // // CONTABO ================================================================================ // aggs: { @@ -72,7 +75,8 @@ class DatasetService { fields: { title: {}, author: {}, - subjects: {} + subjects: {}, + doctype: {} } } }; @@ -333,9 +337,11 @@ class DatasetService { { match: { title: { query: suggestion, fuzziness: "AUTO", boost: 3 } } }, { match: { author: { query: suggestion, fuzziness: "AUTO", boost: 2 } } }, { match: { subjects: { query: suggestion, fuzziness: "AUTO", boost: 1 } } }, + { match: { doctype: { query: suggestion, fuzziness: "AUTO", boost: 1 } } }, { wildcard: { title: { value: `${lowercaseTerm}*`, boost: 3 } } }, { wildcard: { author: { value: `${lowercaseTerm}*`, boost: 2 } } }, - { wildcard: { subjects: { value: `${lowercaseTerm}*`, boost: 1 } } } + { wildcard: { subjects: { value: `${lowercaseTerm}*`, boost: 1 } } }, + { wildcard: { doctype: { value: `${lowercaseTerm}*`, boost: 1 } } } ], minimum_should_match: 1 } @@ -373,7 +379,7 @@ class DatasetService { const filters = Object.entries(activeFilterCategories).map(([category, values]) => { - if (category === "language" || category === "year") { + if (category === "language" || category === "year" || category === "doctype") { return values.map(value => ({ term: { [category]: value } })); } else { return values.map(value => ({ term: { [`${category}.keyword`]: value } })); @@ -435,7 +441,8 @@ class DatasetService { subjects: { terms: { field: "subjects.keyword", size: 1000 } }, // In SOLR is "subject"! language: { terms: { field: "language" } }, // ".keyword" HAS TO BE REMOVED. OTHERWISE BUCKETS ARE NOT OBTAINED FOR THIS author: { terms: { field: "author.keyword", size: 1000 } }, - year: { terms: { field: "year", size: 100 } } // ".keyword" HAS TO BE REMOVED. OTHERWISE BUCKETS ARE NOT OBTAINED FOR THIS + year: { terms: { field: "year", size: 100 } }, // ".keyword" HAS TO BE REMOVED. OTHERWISE BUCKETS ARE NOT OBTAINED FOR THIS + doctype: { terms: { field: "doctype", size: 50 } } // ".keyword" HAS TO BE REMOVED. OTHERWISE BUCKETS ARE NOT OBTAINED FOR THIS }, // CONTABO ================================================================================ // aggs: { @@ -449,7 +456,8 @@ class DatasetService { fields: { title: {}, author: {}, - subjects: {} + subjects: {}, + doctype: {} } } }; diff --git a/src/views/search-view/search-view-component.ts b/src/views/search-view/search-view-component.ts index cf5c3ee..1bd8c32 100644 --- a/src/views/search-view/search-view-component.ts +++ b/src/views/search-view/search-view-component.ts @@ -108,7 +108,7 @@ export default class SearchViewComponent extends Vue { // this.rdrAPI = new DatasetService(); // Trigger search based on provided display and type props if (this.display != "" && this.type != undefined) { - const enumKey: "Title" | "Author" | "Subject" | null = this.getEnumKeyByEnumValue(SearchType, this.type); + const enumKey: "Title" | "Author" | "Subject" | "Doctype" | null = this.getEnumKeyByEnumValue(SearchType, this.type); if (enumKey) { const suggestion = new Suggestion(this.display, "NO-IDEA", SearchType[enumKey]); // const suggestion = new Suggestion(this.display, "" , SearchType[enumKey]);