Correct implementation of tagsAllOf

This commit is contained in:
Chocobozzz 2020-02-14 16:28:11 +01:00
parent 34dcbaa200
commit 8f26b09f11
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 8 additions and 10 deletions

View File

@ -4,7 +4,6 @@ import { flatMap } from 'lodash'
import { Avatar } from '@shared/models'
import { buildSort, elasticSearch } from '../helpers/elastic-search'
import { VideosSearchQuery } from '../types/video-search.model'
import { inspect } from 'util'
function initVideosIndex () {
return elasticSearch.indices.create({
@ -171,24 +170,23 @@ async function queryVideos (search: VideosSearchQuery) {
})
}
// FIXME: rework
if (search.tagsOneOf) {
filter.push({
terms: {
tags: search.tagsOneOf,
minimum_should_match: 1
tags: search.tagsOneOf
}
})
}
if (search.tagsAllOf) {
for (const t of search.tagsAllOf) {
filter.push({
terms: {
tags: search.tagsOneOf,
minimum_should_match: 1
term: {
tags: t
}
})
}
}
if (search.durationMin) {
filter.push({