Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d0ec6da
Add: oneword token search based on the search patter we use
DylanAustin-TheDreamer Mar 24, 2026
4f966ff
removed: line reference comments
DylanAustin-TheDreamer Mar 24, 2026
8643466
add: sutta finder variable at the top for one word query
DylanAustin-TheDreamer Mar 24, 2026
5d5d6c8
Merge branch 'main' of https://github.com/DylanAustin-TheDreamer/budd…
DylanAustin-TheDreamer Mar 25, 2026
d86b787
Merge branch 'main' of https://github.com/DylanAustin-TheDreamer/budd…
DylanAustin-TheDreamer Apr 3, 2026
1860aa4
create: onewordtoken function and TDD - first failed now passes
DylanAustin-TheDreamer Apr 3, 2026
76b34f9
Merge branch 'main' of https://github.com/DylanAustin-TheDreamer/budd…
DylanAustin-TheDreamer Apr 6, 2026
26eff64
trying to get item titles from results array of objects
DylanAustin-TheDreamer Apr 10, 2026
fd5e9db
Merge branch 'main' of https://github.com/DylanAustin-TheDreamer/budd…
DylanAustin-TheDreamer Apr 11, 2026
e799cbc
add: fallback for oneword search results back to results on no results
DylanAustin-TheDreamer Apr 11, 2026
c6f4827
add: findoneword function in completed form with TDD
DylanAustin-TheDreamer Apr 11, 2026
c0649bc
add: new normalizetitle function and better results handling
DylanAustin-TheDreamer Apr 12, 2026
703e8c9
update: findoneword...() with matching against joinedTitles made from…
DylanAustin-TheDreamer Apr 13, 2026
2c16c89
Merge branch 'main' of https://github.com/DylanAustin-TheDreamer/budd…
DylanAustin-TheDreamer Apr 13, 2026
c0be5b6
Merge branches 'dylan-search-function' and 'main' of https://github.c…
DylanAustin-TheDreamer Apr 14, 2026
2905284
add: new test cases to normalizeSuttaTitles
DylanAustin-TheDreamer Apr 16, 2026
55cb72e
Merge branch 'main' of https://github.com/DylanAustin-TheDreamer/budd…
DylanAustin-TheDreamer Apr 16, 2026
24d19d6
add: remove the from beginning, better nikaya index handling and upda…
DylanAustin-TheDreamer Apr 16, 2026
77e02b5
Merge branch 'main' of https://github.com/DylanAustin-TheDreamer/budd…
DylanAustin-TheDreamer Apr 19, 2026
549d6c4
Merge branch 'main' of https://github.com/DylanAustin-TheDreamer/budd…
DylanAustin-TheDreamer Apr 23, 2026
a50ba3c
add: several test cases to match cases suggested on PR review, to sho…
DylanAustin-TheDreamer Apr 23, 2026
8a653f6
Merge branch 'main' of https://github.com/DylanAustin-TheDreamer/budd…
DylanAustin-TheDreamer Apr 25, 2026
332e7e5
Add: extra test cases and new normalizeSuttaTitles() handling
DylanAustin-TheDreamer Apr 25, 2026
d9b6d97
remove: un-used tokenResults variable
DylanAustin-TheDreamer Apr 25, 2026
8907d60
Merge branch 'main' of https://github.com/DylanAustin-TheDreamer/budd…
DylanAustin-TheDreamer Apr 27, 2026
49dd5cd
update: test case names to match test cases properly
DylanAustin-TheDreamer Apr 27, 2026
cf14f49
Merge branch 'main' of https://github.com/DylanAustin-TheDreamer/budd…
DylanAustin-TheDreamer Apr 27, 2026
a2d8a89
update: test case description for testing parse lal sutra
DylanAustin-TheDreamer Apr 27, 2026
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add: oneword token search based on the search patter we use
  • Loading branch information
DylanAustin-TheDreamer committed Mar 24, 2026
commit d0ec6da248ab294762d5c0a1f929d4aea072b4e0
66 changes: 66 additions & 0 deletions assets/js/search_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,72 @@ function displaySearchResults(results) {
function handleSearchMessage(data, searchFn) {
var results = [];
var warning = "";

/* Dylan's edit - the search queries are complex, but here in this function we are certainly testing
user input against our database info. My theory, is first do a oneword check against database titles
joined in one word, if matched show results and if not then go back to our usual methods.

I had AI confirm against all lunr search scripts, that this is the best place to test this theory, and the AI
has implemented this fixed based on the context of our .js scripts.
*/
var oneWordQuery = data.q.trim();
if (oneWordQuery && oneWordQuery.indexOf(" ") === -1) {
try {
results = searchFn(oneWordQuery);
} catch (_) {
results = [];
}
if (!results.length && typeof store !== "undefined" && store) {
var normalizedToken = utils.unaccented(oneWordQuery).toLowerCase().replace(/[^\p{L}\p{N}]/gu, "");
if (normalizedToken) {
var matchedRefs = [];
for (var ref in store) {
var rawTitle = store[ref] && store[ref].title ? store[ref].title : "";
var titleText = Array.isArray(rawTitle) ? rawTitle.join("") : String(rawTitle);
var joinedTitle = utils.unaccented(titleText).toLowerCase().replace(/[^\p{L}\p{N}]/gu, "");

// after joining title, use regex to take away leading nikaya index tokens so we don't get -> an944pannavimuttasuttafreedbywisdom
// and take away any words/characters after sutta
var normalizedJoinedTitle = joinedTitle
.replace(/^(dn|mn|sn|an|snp)\d+(\d+)?/i, "")
.replace(/(sutta).*/i, "$1");

// here I check for sutta in the string like I do on line - 264
const hasSuttaOneWord = /\bsutta\b/i.test(normalizedJoinedTitle);
if(hasSuttaOneWord){
warning = "<li>We have detected the use of sutta. If you don't find what you are looking for - put spaces between the pali words or use sutta finder whilst we improve our searching features</li>" + "<li>" + suttaFinder + "</li>"
}
if (joinedTitle === normalizedToken || normalizedJoinedTitle === normalizedToken) {
matchedRefs.push(ref);
}
}
if (matchedRefs.length) {
results = matchedRefs.map(function(matchedRef) {
return { ref: matchedRef, score: 1, matchData: { metadata: {} } };
});
}
}
}
if (results.length) {
if (data.filterquery && data.filterquery !== "") {
var earlyFilteredResults = searchFn(data.filterquery);
results = results.filter(function(result) {
return earlyFilteredResults.some(function(filteredResult) {
return filteredResult.ref === result.ref;
});
});
}
return {
"warninghtml": warning,
"html": displaySearchResults(results),
"count": results ? results.length : 0,
"q": data.q,
"filterquery": data.filterquery,
"qt": data.qt
};
}
}

var words = data.q.trim().split(" ");
for (var i = 0; i < words.length; i++) {
const s = words[i].trim();
Expand Down