diff --git a/src/App.vue b/src/App.vue index 6dfc470b5897fd24180629342337e329e11bac69..95b1848c22951538c9b111b18d7e416adb0515b5 100644 --- a/src/App.vue +++ b/src/App.vue @@ -99,7 +99,7 @@ export default { return axios.get(self.api_pref + 'suggest?q=' + q).then( function(response) { let hits = q.length ? [{q: q}] : [] - hits = hits.concat(response.data.suggest.suggest[0].options.sort((o1, o2) => o1.text.length - o2.text.length)) + hits = hits.concat(response.data) resolve(hits) }) }) @@ -116,19 +116,19 @@ export default { select_result: function(event) { this.$refs.search.value = '' document.activeElement.blur() - if(event._source){ + if(event.body){ this.$router.push('/' + event._index + '/' + event._id) this.search_results = [] - this.article = event._source + this.article = event history.replaceState({article: this.article, search_results: this.search_results, lang: this.lang}, '') }else{ var self = this self.waiting = true self.article = {lemmas: [], body:{pronunciation: [], definitions: [], etymology: []}} - axios.get(self.api_pref + 'search?q=' + event.q + ' ' + event.q + '*&size=20') + axios.get(self.api_pref + 'search?q=' + event.q) .then(function(response){ self.$router.push('/' + `/search?q=${event.q}&lang=${self.lang}`) - self.search_results = response.data.hits.hits + self.search_results = response.data self.waiting = false history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang}, '') }) @@ -160,9 +160,9 @@ export default { this.lang = this.$route.params.lang || this.$route.query.lang || 'bob,nob' var self = this; if(this.$route.query.q) { - axios.get(self.api_pref + 'search?q=' + self.$route.query.q + ' ' + self.$route.query.q + '*&size=20') + axios.get(self.api_pref + 'search?q=' + self.$route.query.q) .then(function(response){ - self.search_results = response.data.hits.hits + self.search_results = response.data self.waiting = false history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang}, '') }) diff --git a/src/components/Preview.vue b/src/components/Preview.vue index 5c7df1cf381f4b80239dd6af24d76e2b27b47b11..1870a1de057bd726d823c4278036ee432199ba48 100644 --- a/src/components/Preview.vue +++ b/src/components/Preview.vue @@ -26,13 +26,13 @@ export default { }, computed: { previewHeader: function(){ - return this.searchHit.text && this.searchHit.text + " (" + labels[this.searchHit._index] + ")" || - (this.searchHit._source && this.searchHit._source.lemmas.map(l => `${l.lemma}`) || []).join(',') || + return this.searchHit.match && this.searchHit.match + " (" + labels[this.searchHit.dictionary] + ")" || + (this.searchHit.lemmas && this.searchHit.lemmas.map(l => `${l.lemma}`) || []).join(',') || "Alle søkeresultater..." }, previewText: function(){ - if (! this.searchHit._source) return '' - let element = this.searchHit._source.body.definitions[0] || '' + if (! this.searchHit.body) return '' + let element = this.searchHit.body.definitions[0] || '' while (element.type_ == 'definition') element = element.elements[0] if (element.type_ == 'example') { element = element.quote @@ -40,7 +40,7 @@ export default { element = {content: '', items: []} } - let lang = this.searchHit._index + let lang = this.searchHit.dictionary let replacements = element.items.map(item => item.text || item.string || @@ -54,7 +54,7 @@ export default { return element.content.replace(/\$/gi, replacement) }, group_list: function() { - return helpers.group_list(this.searchHit._source.lemmas) + return helpers.group_list(this.searchHit.lemmas) } }, components: { diff --git a/src/components/SearchResults.vue b/src/components/SearchResults.vue index 40db8b184393d08ebc4381e8331cecdf6656a6da..6daf7aae53e376bc99410500727a68cb904223bb 100644 --- a/src/components/SearchResults.vue +++ b/src/components/SearchResults.vue @@ -33,19 +33,19 @@ export default { }, computed: { results_bob: function(){ - return this.hits.filter(hit => hit._index == 'bob') + return this.hits.filter(hit => hit.dictionary == 'bob') }, results_nob: function(){ - return this.hits.filter(hit => hit._index == 'nob') + return this.hits.filter(hit => hit.dictionary == 'nob') }, results_norsk: function(){ - return this.hits.filter(hit => hit._index == 'norsk_ordbok') + return this.hits.filter(hit => hit.dictionary == 'norsk_ordbok') } }, methods: { article_link_click: function(result) { - this.$router.push('/' + result._index + '/' + result._id) - this.$emit('search-hit-click', result._source) + this.$router.push('/' + result.dictionary + '/' + result.article_id) + this.$emit('search-hit-click', result) } }, components: {