@@ -128,16 +128,26 @@ function debounce(func, wait) {
128128// maximum sum. If there are multiple maximas, then get the last one.
129129// Enclose the terms in <b>.
130130function makeTeaser(body, terms) {
131+ console.log("make teaser");
131132 var TERM_WEIGHT = 40;
132133 var NORMAL_WORD_WEIGHT = 2;
133134 var FIRST_WORD_WEIGHT = 8;
134135 //var TEASER_MAX_WORDS = 17;
135136 var TEASER_MAX_CHARS = 63;
136137
138+
137139 var stemmedTerms = terms.map(function (w) {
138140 return elasticlunr.stemmer(w.toLowerCase());
139141 });
140142
143+ console.log(stemmedTerms);
144+ // create array with full word + partial Words (smallest fragment is 2 characters)
145+ // first iteration is full word, then next is subset of the original word
146+ /*var stemmedTerms = [];
147+ for (var i = terms[0].length; i>=2; i--) {
148+ stemmedTerms.push(terms[0].substring(0,i));
149+ }
150+ console.log(stemmedTerms);*/
141151 var termFound = false;
142152 var index = 0;
143153 var weighted = []; // contains elements of ["word", weight, index_in_document]
@@ -238,35 +248,17 @@ function makeTeaser(body, terms) {
238248}
239249
240250function formatSearchResultTitle(path) {
241−// console.log(path);
242251 var pathArray = path.split( '/' );
243− //console.log(pathArray);
244− /*var slug = pathArray[1];
245−// console.log(slug);
246− var slugArray = slug.split( '/' );
247− var lastPartTitle = slugArray.splice(slugArray.length - 2, slugArray.length).join('');
248− var firstPartTitle = slugArray.join(' / ');
249−//console.log(lastPartTitle);
250−//console.log(firstPartTitle);
251−*/
252− var firstPartTitle = pathArray[3]; // first directory is in 4th element of path array
253− var lastPartTitle = pathArray[pathArray.length-2]; // last directory is in 2nd to last element of array
254− var fullTitle = firstPartTitle + '<span class="gray90">' + ' / ' + lastPartTitle + '</span>';
255− console.log(fullTitle);
256− return fullTitle;
257−/*
258− var pathArray = path.split( 'docs/' );
259−// console.log(pathArray);
260− var slug = pathArray[1];
261−// console.log(slug);
262− var slugArray = slug.split( '/' );
263− var lastPartTitle = slugArray.splice(slugArray.length - 2, slugArray.length).join('');
264− var firstPartTitle = slugArray.join(' / ');
252+
253+ // first directory is in 4th element of split path array
254+ var firstPartTitle = pathArray[3];
255+
256+ // last directory is in 2nd to last element of array
257+ var lastPartTitle = pathArray[pathArray.length-2].replace(/-/g,' ');
265258
266259 var fullTitle = firstPartTitle + '<span class="gray90">' + ' / ' + lastPartTitle + '</span>';
267260
268261 return fullTitle;
269− */
270262}
271263
272264function formatSearchResultItem(item, terms) {
@@ -284,6 +276,7 @@ function formatSearchResultItem(item, terms) {
284276}
285277
286278function initSearch() {
279+ console.log("init search");
287280 var searchInput = document.getElementById("search");
288281
289282 if (!searchInput) {
@@ -297,6 +290,7 @@ function initSearch() {
297290
298291 var options = {
299292 bool: "AND",
293+ expand: true,
300294 fields: {
301295 title: {boost: 2},
302296 body: {boost: 1},
@@ -348,6 +342,8 @@ function initSearch() {
348342 return;
349343 }
350344
345+ // change query in order to make partial words work
346+
351347 var results = index.search(term, options).filter(function (r) {
352348 return r.doc.body !== "";
353349 });