forked from geolba/tethys.frontend
Created a first method to test query to OpenSearch
This commit is contained in:
parent
fab69f496b
commit
8962345f99
|
@ -9,6 +9,43 @@ import { VUE_API } from "@/constants";
|
||||||
import { deserialize } from "class-transformer";
|
import { deserialize } from "class-transformer";
|
||||||
|
|
||||||
class DatasetService {
|
class DatasetService {
|
||||||
|
/* Initial test method to fetch and log data from the local OpenSearch endpoint (new backend) */
|
||||||
|
async fetchDataFromOpenSearch(searchTerm: string): Promise<void> {
|
||||||
|
const url = "http://192.168.21.18/tethys-records/_search";
|
||||||
|
const headers = {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
};
|
||||||
|
const body = {
|
||||||
|
query: {
|
||||||
|
match: {
|
||||||
|
title: searchTerm,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(url, {
|
||||||
|
method: "POST",
|
||||||
|
headers: headers,
|
||||||
|
body: JSON.stringify(body),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Failed to fetch data from ${url}, status: ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
console.log("Data from OpenSearch:", data);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching data:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* https://tethys.at/solr/rdr_data/select?&0=fl%3Did%2Clicence%2Cserver_date_published%2Cabstract_output%2Cidentifier%2Ctitle_output%2Ctitle_additional%2Cauthor%2Csubject%2Cdoctype&q=%2A
|
||||||
|
&q.op=or&defType=edismax&qf=title%5E3%20author%5E2%20subject%5E1&indent=on&wt=json&rows=10&start=0&sort=server_date_published%20desc&facet=on&json.facet.language=%7B%20type%3A%20%22
|
||||||
|
terms%22%2C%20field%3A%20%22language%22%20%7D&json.facet.subject=%7B%20type%3A%20%22terms%22%2C%20field%3A%20%22subject%22%2C%20limit%3A%20-1%20%7D&json.facet.year=%7B%20type%3A%20%22
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
|
||||||
/* https://tethys.at/solr/rdr_data/select?&0=fl%3Did%2Clicence%2Cserver_date_published%2Cabstract_output%2Cidentifier%2Ctitle_output%2Ctitle_additional%2Cauthor%2Csubject%2Cdoctype&q=%2A
|
/* https://tethys.at/solr/rdr_data/select?&0=fl%3Did%2Clicence%2Cserver_date_published%2Cabstract_output%2Cidentifier%2Ctitle_output%2Ctitle_additional%2Cauthor%2Csubject%2Cdoctype&q=%2A
|
||||||
&q.op=or&defType=edismax&qf=title%5E3%20author%5E2%20subject%5E1&indent=on&wt=json&rows=10&start=0&sort=server_date_published%20desc&facet=on&json.facet.language=%7B%20type%3A%20%22
|
&q.op=or&defType=edismax&qf=title%5E3%20author%5E2%20subject%5E1&indent=on&wt=json&rows=10&start=0&sort=server_date_published%20desc&facet=on&json.facet.language=%7B%20type%3A%20%22
|
||||||
|
@ -18,6 +55,8 @@ class DatasetService {
|
||||||
|
|
||||||
// For the autocomplete search. Method to perform a search based on a term
|
// For the autocomplete search. Method to perform a search based on a term
|
||||||
public searchTerm(term: string, solrCore: string, solrHost: string): Observable<Dataset[]> {
|
public searchTerm(term: string, solrCore: string, solrHost: string): Observable<Dataset[]> {
|
||||||
|
// Calling the test method for
|
||||||
|
this.fetchDataFromOpenSearch(term);
|
||||||
// solr endpoint
|
// solr endpoint
|
||||||
const host = "https://" + solrHost;
|
const host = "https://" + solrHost;
|
||||||
const path = "/solr/" + solrCore + "/select?";
|
const path = "/solr/" + solrCore + "/select?";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user