Commit 9b35b696 authored by anton's avatar anton

Update from elasticsearch

parents 20e2d721 8e54044f
Pipeline #65073 passed with stages
in 1 minute and 1 second
# Changelog
This document tracks all important changes to the Motion Bank Transcoding Service.
This document tracks all important changes to the Motion Bank API.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
......@@ -9,13 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- [Elasticsearch](https://www.elastic.co) endpoint at `/search`
- [Elasticsearch](https://www.elastic.co) endpoint at `/search` (supports query & aggregations)
- Automatic indexing of objects for `POST`, `PATCH`, `PUT` and removal on `DELETE`
### Updated
- [mbjs-generic-api](https://gitlab.rlp.net/motionbank/mbjs/generic-api)
to 2.6.0
to 2.6.1
## [2.1.0] - 2020-05-06
......
#!/usr/bin/env node
const
config = require('config'),
{ ObjectUtil } = require('mbjs-utils'),
{ MongoDB } = require('mbjs-persistence'),
SearchIndex = require('mbjs-generic-api/src/lib/search-index'),
searchIndexMappings = require('../../src/search-index-mappings')
const main = async function () {
const [node, cmd, index, force] = process.argv
process.stdout.write(`${node} ${cmd}\n`)
process.stdout.write(`Updating index ${index}...\n`)
const searchIndex = new SearchIndex(index, searchIndexMappings[index])
await searchIndex.ensure(!!force)
let count = 0
const client = new MongoDB(ObjectUtil.merge({name: index, logger: console}, config.get('resources.mongodb')), 'id')
const results = await client.find({})
for (const item of results) {
await searchIndex.index(item.id, ObjectUtil.merge({}, item, {_id: undefined}))
count++
if (count % 100 === 0) process.stdout.write(`Items ${count}\n`)
}
process.stdout.write(`Items ${count}\n`)
process.exit(0)
}
main()
......@@ -3,7 +3,8 @@ const
GenericAPI = require('mbjs-generic-api'),
{ version } = require('../package.json'),
{ parseURI } = require('mbjs-data-models/src/lib'),
getTokenFromHeaders = require('mbjs-generic-api/src/util/get-token-from-headers')
getTokenFromHeaders = require('mbjs-generic-api/src/util/get-token-from-headers'),
searchIndexMappings = require('./search-index-mappings')
const setup = async function () {
const services = []
......@@ -68,19 +69,7 @@ const setup = async function () {
}
}
}
}, {
properties: {
'target.selector._valueMillis': {
type: 'date'
},
_created: {
type: 'date'
},
_updated: {
type: 'date'
}
}
})
}, searchIndexMappings.annotations)
// annotations.on('message', message => api._sockets.write(message))
services.push(annotations)
......@@ -106,16 +95,7 @@ const setup = async function () {
}
}
}
}, {
properties: {
_created: {
type: 'date'
},
_updated: {
type: 'date'
}
}
})
}, searchIndexMappings.maps)
// maps.on('message', message => api._sockets.write(message))
services.push(maps)
......
const searchIndexMappings = {
annotations: {
properties: {
'target.selector._valueMillis': {
type: 'date'
},
_created: {
type: 'date'
},
_updated: {
type: 'date'
}
}
},
maps: {
properties: {
_created: {
type: 'date'
},
_updated: {
type: 'date'
}
}
}
}
module.exports = searchIndexMappings
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment