Merge pull request #122 from marcdeb1/nsfw_filter
Added NSFW filter to query
This commit is contained in:
commit
e3e6d7c94d
1 changed files with 23 additions and 3 deletions
|
@ -188,6 +188,7 @@ function getResults (input) {
|
|||
},
|
||||
},
|
||||
],
|
||||
'filter': getFilters(input),
|
||||
},
|
||||
},
|
||||
size: input.size,
|
||||
|
@ -248,10 +249,29 @@ 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) {
|
||||
|
@ -265,7 +285,7 @@ function getAutoComplete (query) {
|
|||
query: {
|
||||
bool: {
|
||||
must : getAutoCompleteQuery(query),
|
||||
filter: getFilter(query),
|
||||
filter: getFilters(query),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue