feat: aws cloudsearch engine (wip)

This commit is contained in:
Nick
2019-03-13 02:52:08 -04:00
parent 21ee8c0c0b
commit c9648371e6
5 changed files with 321 additions and 17 deletions

View File

@@ -14,11 +14,13 @@ module.exports = {
* INIT
*/
async init() {
WIKI.logger.info(`(SEARCH/AZURE) Initializing...`)
this.client = new SearchService(this.config.serviceName, this.config.adminKey)
// -> Create Search Index
const indexes = await this.client.indexes.list()
if (!_.find(_.get(indexes, 'result.value', []), ['name', this.config.indexName])) {
WIKI.logger.info(`(SEARCH/AWS) Creating index...`)
await this.client.indexes.create({
name: this.config.indexName,
fields: [
@@ -75,6 +77,7 @@ module.exports = {
],
})
}
WIKI.logger.info(`(SEARCH/AZURE) Initialization completed.`)
},
/**
* QUERY
@@ -202,6 +205,7 @@ module.exports = {
* REBUILD INDEX
*/
async rebuild() {
WIKI.logger.info(`(SEARCH/AZURE) Rebuilding Index...`)
await pipeline(
WIKI.models.knex.column({ id: 'hash' }, 'path', { locale: 'localeCode' }, 'title', 'description', 'content').select().from('pages').where({
isPublished: true,
@@ -209,5 +213,6 @@ module.exports = {
}).stream(),
this.client.indexes.use(this.config.indexName).createIndexingStream()
)
WIKI.logger.info(`(SEARCH/AZURE) Index rebuilt successfully.`)
}
}