Update Lunr (#1419)
* Update Lunr to 2.1.5 * Remove colons from query string Fixes #1419
This commit is contained in:
parent
6839069b9b
commit
7e6a46c447
@ -3,27 +3,27 @@ layout: null
|
|||||||
---
|
---
|
||||||
|
|
||||||
var idx = lunr(function () {
|
var idx = lunr(function () {
|
||||||
this.field('title', {boost: 10})
|
this.field('title')
|
||||||
this.field('excerpt')
|
this.field('excerpt')
|
||||||
this.field('categories')
|
this.field('categories')
|
||||||
this.field('tags')
|
this.field('tags')
|
||||||
this.ref('id')
|
this.ref('id')
|
||||||
});
|
|
||||||
|
|
||||||
{% assign count = 0 %}
|
{% assign count = 0 %}
|
||||||
{% for c in site.collections %}
|
{% for c in site.collections %}
|
||||||
{% assign docs = c.docs | where_exp:'doc','doc.search != false' %}
|
{% assign docs = c.docs | where_exp:'doc','doc.search != false' %}
|
||||||
{% for doc in docs %}
|
{% for doc in docs %}
|
||||||
idx.add({
|
this.add({
|
||||||
title: {{ doc.title | jsonify }},
|
title: {{ doc.title | jsonify }},
|
||||||
excerpt: {{ doc.content | strip_html | truncatewords: 20 | jsonify }},
|
excerpt: {{ doc.content | strip_html | truncatewords: 20 | jsonify }},
|
||||||
categories: {{ doc.categories | jsonify }},
|
categories: {{ doc.categories | jsonify }},
|
||||||
tags: {{ doc.tags | jsonify }},
|
tags: {{ doc.tags | jsonify }},
|
||||||
id: {{ count }}
|
id: {{ count }}
|
||||||
});
|
})
|
||||||
{% assign count = count | plus: 1 %}
|
{% assign count = count | plus: 1 %}
|
||||||
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
});
|
||||||
|
|
||||||
console.log( jQuery.type(idx) );
|
console.log( jQuery.type(idx) );
|
||||||
|
|
||||||
@ -56,8 +56,19 @@ var store = [
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('input#search').on('keyup', function () {
|
$('input#search').on('keyup', function () {
|
||||||
var resultdiv = $('#results');
|
var resultdiv = $('#results');
|
||||||
var query = $(this).val();
|
var query = $(this).val().toLowerCase().replace(":", "");
|
||||||
var result = idx.search(query);
|
var result =
|
||||||
|
idx.query(function (q) {
|
||||||
|
query.split(lunr.tokenizer.separator).forEach(function (term) {
|
||||||
|
q.term(term, { boost: 100 })
|
||||||
|
if(query.lastIndexOf(" ") != query.length-1){
|
||||||
|
q.term(term, { usePipeline: false, wildcard: lunr.Query.wildcard.TRAILING, boost: 10 })
|
||||||
|
}
|
||||||
|
if (term != ""){
|
||||||
|
q.term(term, { usePipeline: false, editDistance: 1, boost: 1 })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
resultdiv.empty();
|
resultdiv.empty();
|
||||||
resultdiv.prepend('<p class="results__found">'+result.length+' {{ site.data.ui-text[site.locale].results_found | default: "Result(s) found" }}</p>');
|
resultdiv.prepend('<p class="results__found">'+result.length+' {{ site.data.ui-text[site.locale].results_found | default: "Result(s) found" }}</p>');
|
||||||
for (var item in result) {
|
for (var item in result) {
|
||||||
|
2980
assets/js/lunr.min.js
vendored
2980
assets/js/lunr.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user