3421N/A * Sphinx JavaScript utilties for the full-text search. 3421N/A * :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. 3421N/A * :license: BSD, see LICENSE for details. 3421N/A var c =
"[^aeiou]";
// consonant 3421N/A var v =
"[aeiouy]";
// vowel 3421N/A var C = c +
"[^aeiouy]*";
// consonant sequence 3421N/A var V = v +
"[aeiou]*";
// vowel sequence 3421N/A var mgr0 =
"^(" + C +
")?" + V + C;
// [C]VC... is m>0 3421N/A var meq1 =
"^(" + C +
")?" + V + C +
"(" + V +
")?$";
// [C]VC[V] is m=1 3421N/A var mgr1 =
"^(" + C +
")?" + V + C + V + C;
// [C]VCVC... is m>1 3421N/A var s_v =
"^(" + C +
")?" + v;
// vowel in stem 3421N/A re4 =
new RegExp(
"^" + C + v +
"[^aeiouwxy]$");
3421N/A re3 =
new RegExp(
"^" + C + v +
"[^aeiouwxy]$");
3421N/A // and turn initial Y back to y 3421N/A * Simple result scoring code. 3421N/A // Implement the following function to further tweak the score for each result 3421N/A // The function takes a result array [filename, title, anchor, descr, score] 3421N/A // and returns the new score. 3421N/A // query matches the full name of an object 3421N/A // or matches in the last dotted part of the object name 3421N/A // Additive scores depending on the priority of the object 3421N/A 1:
5,
// used to be objectResults 3421N/A 2: -
5},
// used to be unimportantResults 3421N/A // Used when the priority is not in the mapping. 3421N/A * perform a search for something (or wait until index is loaded) 3421N/A // create the required interface elements 3421N/A $(
'#search-progress').
text(_(
'Preparing search...'));
3421N/A // index already loaded, the browser was quick! 3421N/A * execute search (requires search index to be loaded) 3421N/A var stopwords = [
"a",
"and",
"are",
"as",
"at",
"be",
"but",
"by",
"for",
"if",
"in",
"into",
"is",
"it",
"near",
"no",
"not",
"of",
"on",
"or",
"such",
"that",
"the",
"their",
"then",
"there",
"these",
"they",
"this",
"to",
"was",
"will",
"with"];
3421N/A // stem the searchterms and add them to the correct list 3421N/A // only add if not already in the list 3421N/A // console.debug('SEARCH: searching for:'); 3421N/A // console.info('required: ', searchterms); 3421N/A // console.info('excluded: ', excluded); 3421N/A // array of [filename, title, anchor, descr, score] 3421N/A // lookup as search terms in fulltext 3421N/A // let the scorer override scores with a custom scoring function 3421N/A // now sort the results by score (in opposite order of appearance, since the 3421N/A // display function below uses pop() to retrieve items) and then 3421N/A // same score: sort alphabetically 3421N/A //Search.lastresults = results.slice(); // a copy 3421N/A //console.info('search results:', Search.lastresults); 3421N/A // results left, load the summary and display it 3421N/A // no source available, just display title 3421N/A // search finished, update title and status message 3421N/A Search.
status.
text(_(
'Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.'));
3421N/A // check for different match types: exact matches of full name or 3421N/A // "last name" (i.e. last dotted part) 3421N/A // If more than one term searched for, we require other words to be 3421N/A // add custom score for some objects according to scorer 3421N/A * search for full-text terms in the index 3421N/A // perform the search on the required terms 3421N/A // no match but word was a required one 3421N/A // now check if the files don't contain excluded terms 3421N/A // check if all requirements are matched 3421N/A // ensure that none of the excluded terms is in the search result 3421N/A // if we have still a valid result we can add it to the result list 3421N/A * helper function to return a node containing the 3421N/A * search summary for a given text. keywords is a list 3421N/A * of stemmed words, hlwords is the list of normal, unstemmed 3421N/A * words. the first one is used to find the occurance, the 3421N/A * latter for highlighting it.