projectEndings / staticSearch

A codebase to support a pure JSON search engine requiring no backend for any XHTML5 document collection
https://endings.uvic.ca/staticSearch/docs/index.html
Mozilla Public License 2.0
46 stars 21 forks source link

In feature filters, minWordLength should never be longer than the shortest value #267

Closed martindholmes closed 1 month ago

martindholmes commented 1 year ago

Feature filters currently inherit their minWordLength setting from the main StaticSearch class, where it is set primarily for the purposes of stem generation. However, it's possible for a feature filter to have an acceptable value that's shorter than this, and in that case, it's not possible to generate that value to create a checkbox for it. minWordLength for feature filters should be the min of the StaticSearch minWordLength and the min length of the feature filter value set items.

martindholmes commented 1 year ago

Rather than have the JS check the length of every single name in the JSON, I think it would make more sense to calculate this at build time and store it in the filter JSON as an additional property alongside filterId and filterName:

"minNameLength": 2

Then the SSTypeAhead constructor can compare it directly with the minWordLength that's passed to it by the StaticSearch object, and set its internal minWordLength property to the min of the two of them.

@joeytakeda Does that make sense? If so, it's a relatively easy fix in the json.xsl, I think.

martindholmes commented 1 month ago

@joeytakeda has implemented $minNameLength as a param in the feature filter JSON output; over to me to have the JS parse it and use it.