Tests. TODO solving failure with the faceted search with 2 subjects
This commit is contained in:
parent
95c7c8ba7b
commit
32f743c04e
|
@ -88,7 +88,7 @@ export default class VsInput extends Vue {
|
||||||
|
|
||||||
const suggestions = new Array<Suggestion>();
|
const suggestions = new Array<Suggestion>();
|
||||||
|
|
||||||
console.log("getSuggestions > Display:", this.display);
|
// console.log("getSuggestions > Display:", this.display);
|
||||||
// console.log("results:", this.results );
|
// console.log("results:", this.results );
|
||||||
// console.log("highlights:", this.highlights);
|
// console.log("highlights:", this.highlights);
|
||||||
|
|
||||||
|
|
|
@ -70,8 +70,6 @@ class DatasetService {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Make API call to OpenSearch and return the result
|
// Make API call to OpenSearch and return the result
|
||||||
/**
|
/**
|
||||||
* When a POST request is made to the OpenSearch server using the api.post<OpenSearchResponse> method, the response received from OpenSearch is an object that includes various details about the search results.
|
* When a POST request is made to the OpenSearch server using the api.post<OpenSearchResponse> method, the response received from OpenSearch is an object that includes various details about the search results.
|
||||||
|
@ -148,7 +146,7 @@ class DatasetService {
|
||||||
const path = "/" + openCore + "/_search";
|
const path = "/" + openCore + "/_search";
|
||||||
const base = host + path;
|
const base = host + path;
|
||||||
|
|
||||||
const lowercaseTerm = typeof suggestion === 'string' ? suggestion.toLowerCase() : suggestion.value.toLowerCase();
|
const lowercaseTerm = typeof suggestion === 'string' ? suggestion.toLowerCase() : suggestion.value;
|
||||||
|
|
||||||
// console.log("facetedsearchOPEN > suggestion entered:");
|
// console.log("facetedsearchOPEN > suggestion entered:");
|
||||||
// console.log(suggestion);
|
// console.log(suggestion);
|
||||||
|
@ -158,7 +156,7 @@ class DatasetService {
|
||||||
/**
|
/**
|
||||||
* The query construction depends on whether the suggestion is a string or a Suggestion object. */
|
* The query construction depends on whether the suggestion is a string or a Suggestion object. */
|
||||||
// When suggestion is a string:
|
// When suggestion is a string:
|
||||||
const query = typeof suggestion === 'string'
|
const mainQuery = typeof suggestion === 'string'
|
||||||
? {
|
? {
|
||||||
bool: {
|
bool: {
|
||||||
should: [
|
should: [
|
||||||
|
@ -182,11 +180,12 @@ class DatasetService {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Constructing Filters Based on Active Filter Categories
|
// // Constructing Filters Based on Active Filter Categories
|
||||||
// const filters = Object.entries(activeFilterCategories).map(([category, values]) => ({
|
// const filters = Object.entries(activeFilterCategories).map(([category, values]) => ({
|
||||||
// terms: { [`${category}.keyword`]: values }
|
// // terms: { [`${category}.keyword`]: values }
|
||||||
// // terms: { [category]: values }
|
// terms: { [category]: values }
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
const filters = Object.entries(activeFilterCategories).map(([category, values]) => {
|
const filters = Object.entries(activeFilterCategories).map(([category, values]) => {
|
||||||
if (category === "language" || category === "year") {
|
if (category === "language" || category === "year") {
|
||||||
return { terms: { [category]: values } };
|
return { terms: { [category]: values } };
|
||||||
|
@ -194,12 +193,28 @@ class DatasetService {
|
||||||
return { terms: { [`${category}.keyword`]: values } };
|
return { terms: { [`${category}.keyword`]: values } };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// console.log(activeFilterCategories);
|
||||||
|
console.log("mainQuery:", mainQuery);
|
||||||
|
console.log("filters:", filters);
|
||||||
|
|
||||||
const body = {
|
const body = {
|
||||||
|
// query: {
|
||||||
|
// bool: {
|
||||||
|
// must: query, // Contains the main query constructed earlier.
|
||||||
|
// filter: filters // Contains the filters constructed from activeFilterCategories.
|
||||||
|
// // filter: [
|
||||||
|
// // { "terms": { "subjects.keyword": ["Lower Austria", "counting data"] } },
|
||||||
|
// // { "term": { "language": "en" } }
|
||||||
|
// // ] // Contains the filters constructed from activeFilterCategories.
|
||||||
|
// }
|
||||||
|
// },
|
||||||
query: {
|
query: {
|
||||||
bool: {
|
bool: {
|
||||||
must: query, // Contains the main query constructed earlier.
|
must: [
|
||||||
filter: filters // Contains the filters constructed from activeFilterCategories.
|
mainQuery, // Ensure the main query must be satisfied
|
||||||
|
...filters // Ensure all filters must be satisfied
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
size: 10,
|
size: 10,
|
||||||
|
@ -224,6 +239,9 @@ class DatasetService {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log("body:", body);
|
||||||
|
|
||||||
|
|
||||||
const stations = api.post<OpenSearchResponse>(base, body);
|
const stations = api.post<OpenSearchResponse>(base, body);
|
||||||
|
|
||||||
return stations;
|
return stations;
|
||||||
|
|
|
@ -131,7 +131,7 @@ export default class SearchViewComponent extends Vue {
|
||||||
this.activeFilterCategories = new ActiveFilterCategories();
|
this.activeFilterCategories = new ActiveFilterCategories();
|
||||||
this.facets = new FacetResults();
|
this.facets = new FacetResults();
|
||||||
this.searchTerm = suggestion;
|
this.searchTerm = suggestion;
|
||||||
console.log("ONSEARCH > suggestion: ", suggestion);
|
// console.log("ONSEARCH > suggestion: ", suggestion);
|
||||||
|
|
||||||
// /* Perform faceted search. The method returns an Observable, and the code subscribes to this Observable to handle the response. If the response is successful, it calls the dataHandler method
|
// /* Perform faceted search. The method returns an Observable, and the code subscribes to this Observable to handle the response. If the response is successful, it calls the dataHandler method
|
||||||
// with the Solr response as a parameter. If there is an error, it calls the errorHandler method with the error message as a parameter */
|
// with the Solr response as a parameter. If there is an error, it calls the errorHandler method with the error message as a parameter */
|
||||||
|
@ -157,10 +157,10 @@ export default class SearchViewComponent extends Vue {
|
||||||
// console.log(this.results);
|
// console.log(this.results);
|
||||||
// console.log(this.numFound);
|
// console.log(this.numFound);
|
||||||
// console.log(res.hits.hits);
|
// console.log(res.hits.hits);
|
||||||
// console.log(res.hits.total.value);
|
// console.log(res.hits.total.value); console.log(res);
|
||||||
|
// console.log("results:");
|
||||||
console.log(res);
|
console.log(res);
|
||||||
|
|
||||||
|
|
||||||
// for (const key in this.results) {
|
// for (const key in this.results) {
|
||||||
// if (Object.prototype.hasOwnProperty.call(this.results, key)) {
|
// if (Object.prototype.hasOwnProperty.call(this.results, key)) {
|
||||||
// const element = this.results[key];
|
// const element = this.results[key];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user