-
-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting filters, stemmers, ... to work #278
Comments
@WesleyMConner Does this explain why I can't get stemming to work at all? #280 |
Apologies for the delayed response. I have been tied up with jury duty this week. I have only worked with For context, I attempt to restrict my code to relatively pure ES6 and very up to date / minimal modules (i.e., avoiding Babel, Gulp, …). I make heavy use of Gitpod, VsCode and Jest which requires more than a little experimentation to stabilize give ES6 purity objectives and pre-releases of both FlexSearch (https://www.npmjs.com/package/flexsearch/v/0.7.21) and Antora 3 (3.0.0-alpha.9). My application requires generation of an Index on the server (extending Antora 3) and using the Index by a client with zero server interaction once the code is pulled down. I have an ES6 base class that wraps/extends a FlexSearch.Index instance - e.g., overloading add(), search(), and introducing application specific extensions, etc. My base class DOES NOT create the FlexSearch.Index nor does it include export or import methods. I have a server-specific base class extension that creates a FlexSearch.Index instance and adds both export and import methods. [The import methods exist for server-side Jest tests only.] I have a client-specific base class extension that creates a FlexSearch.Index and adds an import method. [Currently, the server and client import implementations are the same; so, I could re-factored to avoid repeating the same import code.] I create and use the following object instance to help ensure consistency when initializing new FlexSearch.Index instances across server and client implementations. The object references local copies of referenced filters, stemmers, etc. which must be present in both server and client contexts. Since the server class extension and client class extension both use this object instance, I do not have to worry about slight discrepancies emerging between how the server and client FlexSearch.Index instances are initialized.
The server class extension creates a FlexSearch.Index instance using The client class extension creates a FlexSearch instance using
The server class has an
The server class has a companion
The server/client import method(s) leverage a
CaveatsI noticed some cases where the FlexSearch export Promise appeared to resolve BEFORE the files were in an import-ready state. Typically my small-index Jest tests would pass even if a server-side import occurred immediately after a server-side export. Once I started using application-scale FlexSearch indexes (i.e., longer write times), I noticed that the FlexSearch export a would resolve its Promise too quickly - before the exported files were sufficiently stable for import. I added an artificial delay (e.g., sleep promise) to the FlexSearch export promise which resolved the issue. I noticed that recent FlexSearch commits have tweaked the export-callback code; so, I eagerly look forward to a prospective FlexSearch 0.7.22 release which I suspect would clean up the Promise logic and perhaps address #273. Net: I am very happy with the latest from both the FlexSearch and Antora projects and look forward to using the combination even in their preliminary release forms. |
That's a very long story :) import { stemmer, filter } from "./vendored/en.mjs";
const ownStemmer = Object.assign(
{
ies: "y",
s: "",
},
stemmer
);
const index = new FlexSearch.Index({
tokenize: "forward",
filter: filter,
stemmer: ownStemmer,
}); that solves it, but it feels hacky and weird to have to do. |
The reason why programmers are confused is that flexsearch runs very fast, but documents are confusing. Unfortunately, I thought he would work, but it didn't work as expected |
Initially, I was successful:
I spent the better part of the morning trying to understand why filters, stemmers, etc. were being ignored. From experimentation, I have two takeaways:
./dist/module/lang/latin/advanced.js
,./dist/module/lang/en.js
and their dependencies in our projects and import them separately from Flexsearch itself.performance
preset, which seems to disable these options.With the local
./dist/**
directory (see above) and theperformance
preset commented out,the filters, stemmers, ... worked as expected.
Is this the correct and expected approach?
The text was updated successfully, but these errors were encountered: