Commit 5a702253 authored by Anton Koch's avatar Anton Koch

Merge branch 'search' into 'release_2_2'

Add Elasticsearch endpoint

See merge request !135
parents 2f8afc9a aa4ef6ba
Pipeline #65051 passed with stage
in 2 minutes and 47 seconds
......@@ -64,6 +64,21 @@
}
catch (e) { this.media[i].metadata = {} }
}
// const aggs = {
// annotations_per_minute: {
// date_histogram: {
// field: 'target.selector._valueMillis',
// calendar_interval: '1m'
// }
// }
// }
// const query = {
// match: { 'target.id': this.map.id }
// }
// const aggregations = await this.$store.dispatch('search/query', { index: 'annotations', aggs, query })
// console.debug('Aggregations', aggregations)
this.$q.loading.hide()
},
computed: {
......@@ -75,12 +90,11 @@
async search () {
this.$q.loading.show()
const query = {
'target.id': this.map.id,
'body.type': 'TextualBody',
'body.value': RegExp(`.*${this.query}.*`, 'ig')
match: { 'body.value': this.query }
}
const result = await this.$store.dispatch('annotations/find', query)
this.results = result && Array.isArray(result.items) ? result.items.sort(this.$sort.onRef) : []
const result = await this.$store.dispatch('search/query', { index: 'annotations', query })
this.results = (result && Array.isArray(result.hits) ? result.hits.sort(this.$sort.onRef) : [])
.map(hit => hit._source)
this.$q.loading.hide()
},
formatDate (millis) {
......@@ -94,7 +108,7 @@
videoEnd = videoStart.plus(video.metadata.duration * 1000)
if (annoTime >= videoStart && annoTime < videoEnd) return video
}
return {}
return { annotation: {}, metadata: {} }
}
}
}
......
......@@ -30,7 +30,8 @@ import {
queue,
swimLane,
vocabularies,
settings
settings,
search
} from './modules'
import mediaFactory from './modules/media'
......@@ -115,7 +116,8 @@ const modules = {
queue,
swimLane,
vocabularies,
settings
settings,
search
}
for (let key in mobaApiModules) {
if (mobaApiModules[key]) modules[key] = mobaApiModules[key]
......
......@@ -10,6 +10,7 @@ import files from './files'
import queue from './queue'
import swimLane from './swim-lane'
import settings from './settings'
import search from './search'
import vocabularies from './vocabularies'
export {
......@@ -25,5 +26,6 @@ export {
queue,
swimLane,
settings,
search,
vocabularies
}
const axios = require('axios')
const search = {
namespaced: true,
state: {},
actions: {
async query (context, { index, query, aggs }) {
const config = {
headers: {
Authorization: `${this.$router.app.$auth.tokenType} ${this.$router.app.$auth.token}`
}
}
let result = await axios.post(`${process.env.API_HOST}/search/${index}`, { query, aggs }, config)
return result.data
}
}
}
export default search
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