2023-11-13 10:06:43 +01:00
|
|
|
import { QueueObject } from 'async'
|
2021-06-24 15:18:54 +02:00
|
|
|
import { logger } from '../../helpers/logger'
|
2023-11-09 14:34:36 +01:00
|
|
|
import { AbstractIndexer, QueueParam } from './shared'
|
|
|
|
import { CONFIG, SORTABLE_COLUMNS } from '../../initializers/constants'
|
|
|
|
import { formatVideoForDB } from '../meilisearch/meilisearch-videos'
|
2021-06-24 15:18:54 +02:00
|
|
|
import { getVideo } from '../requests/peertube-instance'
|
2023-11-09 14:34:36 +01:00
|
|
|
import { DBVideo, IndexableVideo } from '../../types/video.model'
|
2021-06-24 15:18:54 +02:00
|
|
|
|
|
|
|
export class VideoIndexer extends AbstractIndexer <IndexableVideo, DBVideo> {
|
2023-11-13 10:06:43 +01:00
|
|
|
protected readonly indexQueue: QueueObject<QueueParam>
|
2023-11-09 14:34:36 +01:00
|
|
|
protected readonly primaryKey = 'uuid'
|
|
|
|
protected readonly filterableAttributes = [
|
|
|
|
'uuid',
|
|
|
|
'host',
|
|
|
|
'account.handle',
|
|
|
|
'account.host',
|
|
|
|
'publishedAt',
|
|
|
|
'originallyPublishedAt',
|
|
|
|
'nsfw',
|
|
|
|
'category.id',
|
|
|
|
'licence.id',
|
|
|
|
'language.id',
|
|
|
|
'tags',
|
|
|
|
'duration',
|
|
|
|
'isLive'
|
|
|
|
]
|
|
|
|
|
|
|
|
protected readonly sortableAttributes = SORTABLE_COLUMNS.VIDEOS_SEARCH
|
|
|
|
|
|
|
|
// Keep the order, most important first
|
|
|
|
protected readonly searchableAttributes = [
|
|
|
|
'name',
|
|
|
|
'tags',
|
|
|
|
'account.displayName',
|
|
|
|
'channel.displayName',
|
2023-11-13 11:01:17 +01:00
|
|
|
'searchableDescription'
|
2023-11-09 14:34:36 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
protected readonly rankingRules = [
|
|
|
|
"words",
|
|
|
|
"typo",
|
|
|
|
"proximity",
|
|
|
|
"attribute",
|
|
|
|
"sort",
|
|
|
|
"exactness",
|
|
|
|
'language:asc',
|
|
|
|
'views:desc'
|
|
|
|
]
|
2021-06-24 15:18:54 +02:00
|
|
|
|
|
|
|
constructor () {
|
2023-11-09 14:34:36 +01:00
|
|
|
super(CONFIG.MEILISEARCH.INDEXES.VIDEOS, formatVideoForDB)
|
2021-06-24 15:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async indexSpecificElement (host: string, uuid: string) {
|
|
|
|
const video = await getVideo(host, uuid)
|
|
|
|
|
|
|
|
logger.info('Indexing specific video %s of %s.', uuid, host)
|
|
|
|
|
2023-11-09 14:34:36 +01:00
|
|
|
return this.indexElements([ video ])
|
2021-07-28 13:25:39 +02:00
|
|
|
}
|
2021-06-24 15:18:54 +02:00
|
|
|
}
|