forked from geolba/tethys.frontend
OpenSearch: almost implemented, fixing case sensitive issues
This commit is contained in:
parent
4f53411d07
commit
9b8b2bd5ac
8 changed files with 184 additions and 60 deletions
|
@ -3,7 +3,7 @@ import api from "../api/api";
|
|||
import { Observable } from "rxjs";
|
||||
import { tap, map } from "rxjs/operators";
|
||||
import { Dataset, DbDataset, Suggestion } from "@/models/dataset";
|
||||
import { OpenSearchResponse, SolrResponse } from "@/models/headers";
|
||||
import { HitHighlight, OpenSearchResponse, SolrResponse } from "@/models/headers";
|
||||
import { ActiveFilterCategories } from "@/models/solr";
|
||||
import { VUE_API } from "@/constants";
|
||||
import { deserialize } from "class-transformer";
|
||||
|
@ -147,9 +147,11 @@ class DatasetService {
|
|||
terms%22%2C%20field%3A%20%22year%22%20%7D&json.facet.author=%7B%20type%3A%20%22terms%22%2C%20field%3A%20%22author_facet%22%2C%20limit%3A%20-1%20%7D
|
||||
*/
|
||||
|
||||
private openSearchUrl = "http://opensearch.geoinformation.dev/tethys-records/_search";
|
||||
// private openSearchUrl = "http://opensearch.geoinformation.dev/tethys-records/_search";
|
||||
private openSearchUrl = "http://192.168.21.18/tethys-records/_search";
|
||||
|
||||
public searchTerm(term: string): Observable<Dataset[]> {
|
||||
// public searchTerm(term: string): Observable<Dataset[]> {
|
||||
public searchTerm(term: string): Observable<{ datasets: Dataset[], highlights: HitHighlight[] }> {
|
||||
const body = {
|
||||
query: {
|
||||
bool: {
|
||||
|
@ -189,20 +191,16 @@ class DatasetService {
|
|||
* It is used the pipe method to chain RxJS operators to the Observable returned by api.get. The map operator is used to transform the emitted items of the Observable.
|
||||
*/
|
||||
return api.post<OpenSearchResponse>(this.openSearchUrl, body).pipe(
|
||||
// tap(response => console.log("OpenSearchResponse:", response)), // Log the complete response
|
||||
tap(response => console.log("OpenSearchResponse:", response)), // Log the complete response
|
||||
// tap(response => console.log("Aggre:", response.aggregations?.subjects.buckets[0])), // log the first subject of the array of subjects returned
|
||||
// tap(response => console.log("Hits:", response.hits)), // log the first subject of the array of subjects returned
|
||||
|
||||
map(response => response.hits.hits.map(hit => hit._source))
|
||||
// map(response => response.hits.hits.map(hit => hit._source))
|
||||
|
||||
// map(response => response.hits.hits.map(hit => {
|
||||
// const source = hit._source;
|
||||
// const highlights = hit._highlight || {};
|
||||
// return {
|
||||
// ...source,
|
||||
// highlights
|
||||
// };
|
||||
// }))
|
||||
map(response => ({
|
||||
datasets: response.hits.hits.map(hit => hit._source),
|
||||
highlights: response.hits.hits.map(hit => hit.highlight)
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue