Commit d2ab27b1 authored by Bernhard Geier's avatar Bernhard Geier
Browse files

improve trash filtering (self publishing): do not show books with publishers...

improve trash filtering (self publishing): do not show books with publishers containing one of the author's names
parent 9cbab884
......@@ -66,8 +66,11 @@
// retrieve max. NUM results at once
var query_limit = 10;
// filter out "trash"
var query_no_trash = 'NOT publisher:(autorenservices OR cora OR norderstedt OR bookrix OR self-publishing OR selfpublishing OR "independent publishing" OR "direct publishing" OR epubli OR independent OR lyx OR mira OR neobooks OR beatrice OR addictive OR kelter OR "amazon crossing" OR like-erotica OR "me and the muse" OR dreamspinner) AND publisher:[* TO *]';
// list of "trash" publisher substrings
var query_no_trash = 'NOT publisher:(autorenservices OR cora OR norderstedt OR bookrix OR self-publishing OR selfpublishing \
OR "independent publishing" OR "direct publishing" OR epubli OR independent OR lyx OR mira OR neobooks OR beatrice OR addictive OR kelter \
OR "amazon crossing" OR like-erotica OR "me and the muse" OR dreamspinner OR "cursed verlag" OR "rateabull" OR "zeilenfluss" \
OR "pure passion") AND publisher:[* TO *]';
var query_params = {
'text' : null,
......@@ -122,7 +125,34 @@
if (data['responseHeader']['status'] != 0) {
$('#status').addClass('error').text('Keine Treffer');
}
else {
else {
// if trash filter is selected: filter out self-published books from result (check if publisher contains part of author's name)
if (!$("#search_trash_yes").prop("checked")) {
for (var i=data['response']['docs'].length-1; i>=0; i--) {
if ((data['response']['docs'][i]['author']) && (data['response']['docs'][i]['publisher'])) {
var publisher=data['response']['docs'][i]['publisher'];
var author_names = data['response']['docs'][i]['author'][0].split(/[(\s*,?\s+)]/);
// compare all names of the author with the publisher's name
for (var a=0; a<author_names.length; a++) {
// ...but only names longer than 4 characters
if (author_names[a].length < 4) {
break;
}
// in case of a match remove this book from the result set
const regex = new RegExp('.*'+author_names[a]+'.*','i');
if (publisher[0].match(regex)) {
data['response']['numFound']--;
data['response']['docs'].splice(i,1);
break;
}
}
}
}
}
num_docs = data['response']['numFound'];
start = data['response']['start'];
var end = start + query_limit;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment