diff --git a/src/App.vue b/src/App.vue index 04067e3153b339c887f484a144cbea3fa546bc1f..0fe622af70bf4cd492fde04f2519b95f624b987e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -125,7 +125,7 @@ export default { this.lang = this.$route.params.lang || 'nob' var self = this; if(this.$route.query.q) { - axios.get(api_endpoint + '/' + self.lang + '/_search?q=' + self.$route.query.q) + axios.get(api_endpoint + '/' + self.lang + '/_search?q=' + self.$route.query.q + '&sort=_score') .then(function(response){ self.search_results = response.data.hits.hits self.waiting = false diff --git a/src/components/Preview.vue b/src/components/Preview.vue index 2a556eb78fedd62ca86f78c8e81834c070740f5a..cdc28b727c75ccf4ccecf6bb538d4c83e6ac5af8 100644 --- a/src/components/Preview.vue +++ b/src/components/Preview.vue @@ -2,7 +2,7 @@ <li> <div class="preview"> <h4>{{searchHit.text || - (searchHit._source && searchHit._source.lemmas.map(l => l.lemma) || []).join(',') || + (searchHit._source && searchHit._source.lemmas.map(l => l.lemma) || []).join(',') || "Alle søkeresultater..."}}</h4> <h5 v-if="searchHit._source">{{group_list}}</h5> {{previewText.substring(0, 40) + (previewText ? '...' : '')}} @@ -23,7 +23,7 @@ export default { computed: { previewText: function(){ if (! this.searchHit._source) return '' - let element = this.searchHit._source.body.definitions[0] + let element = this.searchHit._source.body.definitions[0] || '' while (element.type_ == 'definition') element = element.elements[0] if (element.type_ == 'example') { element = element.quote