Skip to content
Snippets Groups Projects
Commit f7d54c1e authored by Ole Voldsæter's avatar Ole Voldsæter
Browse files

sorter etter score

parent ad3f3cee
No related branches found
No related tags found
No related merge requests found
...@@ -125,7 +125,7 @@ export default { ...@@ -125,7 +125,7 @@ export default {
this.lang = this.$route.params.lang || 'nob' this.lang = this.$route.params.lang || 'nob'
var self = this; var self = this;
if(this.$route.query.q) { 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){ .then(function(response){
self.search_results = response.data.hits.hits self.search_results = response.data.hits.hits
self.waiting = false self.waiting = false
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<li> <li>
<div class="preview"> <div class="preview">
<h4>{{searchHit.text || <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> "Alle søkeresultater..."}}</h4>
<h5 v-if="searchHit._source">{{group_list}}</h5> <h5 v-if="searchHit._source">{{group_list}}</h5>
{{previewText.substring(0, 40) + (previewText ? '...' : '')}} {{previewText.substring(0, 40) + (previewText ? '...' : '')}}
...@@ -23,7 +23,7 @@ export default { ...@@ -23,7 +23,7 @@ export default {
computed: { computed: {
previewText: function(){ previewText: function(){
if (! this.searchHit._source) return '' 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] while (element.type_ == 'definition') element = element.elements[0]
if (element.type_ == 'example') { if (element.type_ == 'example') {
element = element.quote element = element.quote
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment