Added NSFW filter to query

This commit is contained in:
marcdeb1 2018-10-17 11:42:25 +02:00
parent 59675a89ec
commit 44ea0093ef

View file

@ -184,6 +184,7 @@ function getResults (input) {
},
},
],
'filter': getFilters(input)
},
},
size: input.size,
@ -223,10 +224,30 @@ function getAutoCompleteQuery (query) {
};
}
function getFilter (query) {
function getFilters (input) {
// this is the best place for putting things like filtering on the type of content
// Perhaps we can add search param that will filter on how people have categorized / tagged their content
var filters = [];
if(input.nsfw === "true" || input.nsfw === "false") {
const nsfwFilter = {"match": {"value.stream.metadata.nsfw": input.nsfw}}
filters.push(nsfwFilter);
}
if(filters.length > 0) {
const filterQuery = {
"nested": {
"path": "value",
"query": {
"bool": {
"must": filters
}
}
}
};
return filterQuery;
}
else {
return [];
}
}
function getAutoComplete (query) {