2019-10-03 18:54:05 +02:00
|
|
|
import axios from "axios";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
2019-10-10 12:58:13 +02:00
|
|
|
async search(term, filterItems) {
|
2019-10-03 18:54:05 +02:00
|
|
|
// solr endpoint
|
|
|
|
// const host = 'http://voyagerdemo.com/';
|
2019-10-04 16:13:29 +02:00
|
|
|
const host = 'https://repository.geologie.ac.at/';
|
2019-10-03 18:54:05 +02:00
|
|
|
const path = 'solr/rdr_data/select';
|
|
|
|
const fields = 'id,server_date_published,abstract_output,title_output,title_additional,author,subject'; // fields we want returned
|
2019-10-04 16:13:29 +02:00
|
|
|
const dismaxFields = "title^3 abstract^2 subject^1";
|
2019-10-10 12:58:13 +02:00
|
|
|
const facetFields = "facet.field=language&facet.field={!key=datatype}doctype&facet.field=subject";//&fq=year:(2019)";//&facet.query=year:2018";
|
|
|
|
|
|
|
|
var filterFields = "";
|
|
|
|
// filterItems.forEach(function (item) {
|
|
|
|
// console.log(item.value + " " + item.category);
|
|
|
|
// filterFields += "&fq=" + item.category +":("+ item.value + ")";
|
|
|
|
// });
|
|
|
|
Object.entries(filterItems).forEach(([key, valueArray]) => {
|
|
|
|
// console.log(`${key} ${valueArray}`);
|
|
|
|
valueArray.forEach(function (value) {
|
|
|
|
filterFields += "&fq=" + key +":("+ value + ")";
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2019-10-04 16:13:29 +02:00
|
|
|
|
2019-10-03 18:54:05 +02:00
|
|
|
// $dismax->setQueryFields('title^3 abstract^2 subject^1');
|
2019-10-10 12:58:13 +02:00
|
|
|
const api = `${host}${path}?defType=dismax&q=${term}&fl=${fields}&qf=${dismaxFields}&facet=on&${facetFields}&${filterFields}&wt=json&rows=20&indent=on`;
|
2019-10-04 16:13:29 +02:00
|
|
|
|
|
|
|
const res = await axios.get(api);
|
2019-10-03 18:54:05 +02:00
|
|
|
return res.data;//.response;//.docs;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|