forked from geolba/tethys.frontend
Addition of "doctype"/datatype as another possible facet and search element to use
This commit is contained in:
parent
110c2db8bf
commit
03a55f6a58
|
@ -34,6 +34,8 @@ export default class ActiveFacetCategory extends Vue {
|
|||
return "creator";
|
||||
case "subjects":
|
||||
return "keyword";
|
||||
case "doctype":
|
||||
return "datatype";
|
||||
default:
|
||||
return this.categoryName;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ export default class FacetCategory extends Vue {
|
|||
return "creator";
|
||||
case "subjects":
|
||||
return "keyword";
|
||||
case "doctype":
|
||||
return "datatype";
|
||||
default:
|
||||
return this.filterName;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -96,11 +96,13 @@ export interface HitHighlight {
|
|||
subjects?: Array<string>;
|
||||
title?: Array<string>;
|
||||
author?: Array<string>;
|
||||
doctype?: Array<string>;
|
||||
}
|
||||
|
||||
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<Bucket>;
|
||||
}
|
||||
|
||||
export interface Doctype {
|
||||
doc_count_error_upper_bound: number;
|
||||
sum_other_doc_count: number;
|
||||
buckets: Array<Bucket>;
|
||||
}
|
||||
|
||||
export interface Bucket {
|
||||
key: string;
|
||||
doc_count: number;
|
||||
|
|
|
@ -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: {}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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]);
|
||||
|
|
Loading…
Reference in New Issue
Block a user