Closed diego898 closed 6 years ago
Hi @diego898, and thanks for reporting this! I actually just discovered this bug myself last week while working on a new version - it's because while the initial index ignores non-text tiddlers, the change detection hook does not. A fix is coming in 0.0.5, which should be out this week - in the meantime, you can hotfix this by overwriting $:/plugins/hoelzro/full-text-search/hooks.js
with the following code:
"use strict";
/*\
title: $:/plugins/hoelzro/full-text-search/hooks.js
type: text/vnd.tiddlywiki
module-type: startup
\*/
var SaveTiddlerHook;
(function (SaveTiddlerHook) {
var getIndex = require('$:/plugins/hoelzro/full-text-search/shared-index.js').getIndex;
$tw.hooks.addHook('th-saving-tiddler', function (tiddler) {
var type = tiddler.fields.type || 'text/vnd.tiddlywiki';
if(type.startsWith('text/')) {
getIndex().update(tiddler.fields);
}
return tiddler;
});
$tw.hooks.addHook('th-deleting-tiddler', function (tiddler) {
getIndex().remove({ title: tiddler.fields.title });
});
})(SaveTiddlerHook || (SaveTiddlerHook = {}));
// vim:sts=4:sw=4
Hi again @diego898 - I'm happy to report that I've released the latest version of this plugin - you can get the latest version at https://hoelz.ro/files/fts.html
Hey @hoelzro thanks very much! I can confirm this is now fixed for me so I will close this issue.
A side question: Where can I see/edit the list of ignored words?
Thanks!
@diego898 Currently, the plugin ignores system tiddlers and those with a type not beginning with "text/" (treating tiddlers without a type as "text/vnd.tiddlywiki"). I was thinking about adding a new feature to allow a custom filter on top of this
Hey @hoelzro, I saw on google groups you mentioned that certain "stop words" like the, and etc are ignored. I was just wondering if those stop words are listed in a tiddler somewhere?
Ah, gotcha! So the stop words are currently hardcoded into lunr.js, which is the search library I use. I've been thinking about adding support for non-English languages; is this what you would use it for, or do you just want to add custom stop words?
I just wanted to know all the stop words, and perhaps some of my own, but all in english
So all of the stop words currently in use are here: https://github.com/olivernn/lunr.js/blob/f4f25aecbf95ddba2106fc2d3317a46a318a55f9/lib/stop_word_filter.js#L41
I hadn't thought to make custom stop words a feature - I'll add it to the list =)
I have a node installation of tw5 on my machine, and I was using your excellent plugin when I discovered the following possible bug. This is replicated on a fresh node version of tw5 with your plugin:
This produces the following error popup:
And in the javascript console, I see:
After disabling your plugin, I can then rename the tiddler as usual.