Fix mappings

This commit is contained in:
Chocobozzz 2021-07-28 13:25:39 +02:00
parent 8a7e2b62d6
commit 101d9db656
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 17 additions and 4 deletions

View File

@ -1,7 +1,7 @@
import { logger } from '../../helpers/logger'
import { CONFIG } from '../../initializers/constants'
import { DBChannel, IndexableChannel } from '../../types/channel.model'
import { formatChannelForDB } from '../elastic-search/elastic-search-channels'
import { buildChannelsMapping, formatChannelForDB } from '../elastic-search/elastic-search-channels'
import { getChannel } from '../requests/peertube-instance'
import { AbstractIndexer } from './shared'
@ -24,4 +24,8 @@ export class ChannelIndexer extends AbstractIndexer <IndexableChannel, DBChannel
return this.indexElements([ channel ], true)
}
buildMapping () {
return buildChannelsMapping()
}
}

View File

@ -1,6 +1,6 @@
import { CONFIG } from '../../initializers/constants'
import { DBPlaylist, IndexablePlaylist } from '../../types/playlist.model'
import { formatPlaylistForDB } from '../elastic-search/elastic-search-playlists'
import { buildPlaylistsMapping, formatPlaylistForDB } from '../elastic-search/elastic-search-playlists'
import { AbstractIndexer } from './shared'
export class PlaylistIndexer extends AbstractIndexer <IndexablePlaylist, DBPlaylist> {
@ -13,4 +13,8 @@ export class PlaylistIndexer extends AbstractIndexer <IndexablePlaylist, DBPlayl
// We don't need to index a specific element yet, since we have all playlist information in the list endpoint
throw new Error('Not implemented')
}
buildMapping () {
return buildPlaylistsMapping()
}
}

View File

@ -14,6 +14,7 @@ export abstract class AbstractIndexer <T extends IndexableDoc, DB> {
protected readonly indexQueue: AsyncQueue<QueueParam>
abstract indexSpecificElement (host: string, uuid: string): Promise<any>
abstract buildMapping (): object
constructor (
protected readonly indexName: string,
@ -33,7 +34,7 @@ export abstract class AbstractIndexer <T extends IndexableDoc, DB> {
}
initIndex () {
return buildIndex(this.indexName, buildVideosMapping())
return buildIndex(this.indexName, this.buildMapping())
}
scheduleIndexation (host: string, identifier: string) {

View File

@ -1,7 +1,7 @@
import { logger } from '../../helpers/logger'
import { CONFIG } from '../../initializers/constants'
import { DBVideo, IndexableVideo } from '../../types/video.model'
import { formatVideoForDB } from '../elastic-search/elastic-search-videos'
import { buildVideosMapping, formatVideoForDB } from '../elastic-search/elastic-search-videos'
import { getVideo } from '../requests/peertube-instance'
import { AbstractIndexer } from './shared'
@ -18,4 +18,8 @@ export class VideoIndexer extends AbstractIndexer <IndexableVideo, DBVideo> {
return this.indexElements([ video ], true)
}
buildMapping () {
return buildVideosMapping()
}
}