Added NSFW filter to query
This commit is contained in:
parent
59675a89ec
commit
44ea0093ef
1 changed files with 25 additions and 4 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue