StaticSearch v0.7.0 update
728 words, 4-minute read

StaticSearch v0.7.0 was released on . There should be no breaking changes but there are a few new features included fuzzier results generation.
Fuzzy search results #
StaticSearch now finds partial segments of words so there’s less need to type them in full.
When you type the characters
"exp", the results show pages containing words such as “expert”, “explain”, “explicit”, “explore”, “export”, and “express”.Changing the search term to
"expl"returns pages with the words “explain”, “explicit”, and “explore”.Changing it to
"expla"then returns pages with “explain”.
A fuzzy setting determines the maximum number of words to fetch. Set it on the web component:
HTML excerpt
<static-search fuzzy="5">
<p>search</p>
</static-search>
the bind module <input> field:
HTML excerpt
<input type="search" id="staticsearch_search" fuzzy="5">
or as the second argument of the API .find() method:
JavaScript excerpt
const result = await staticsearch.find('my search query', 5);
- The default
fuzzyvalue is6. Searching for"exp"returns results for all six words above. - Setting
fuzzy="3"returns results for the first three words (“expert”, “explain”, and “explicit”). - Setting
fuzzy="1"or lower reverts to the original search behaviour and the user must type most of the word before results appear.
Keyboard-focusable activation #
The <static-search> activation element which triggers the search dialog is now keyboard-focusable so you can open it by hitting Enter or space.
Activate search from any element #
When using the <static-search> web component, any HTML element can trigger the search dialog by adding a data-static-search attribute, e.g.
HTML excerpt
<a href="#" data-static-search="search">click here to search</a>
Activation element ::part name #
The activation element sets a part attribute name of activate unless you define your own, e.g.
HTML excerpt
<static-search fuzzy="5">
<p part="trigger">search</p>
</static-search>
Style it using the part name, e.g.
CSS excerpt
static-search::part(trigger) {
color: #00f;
}
Build directory location #
The StaticSearch indexer now looks for static sites built to the subdirectories:
./build/./dist/./dest/./out/, or./target/
When none exist, it uses the current working directory.
Omit default stop words #
StaticSearch automatically removes common stop words considered insignificant to the meaning of text – such as “and”, “the”, and “but” in English. It supports stop words in Afrikaans (af), Croatian (hr), Czech (cs), Danish (da), Dutch (nl), English (en), Estonian (et), Finnish (fi), French (fr), German (de), Hungarian (hu), Irish (ga), Italian (it), Latvian (lv), Lithuanian (lt), Malay (ms), Norwegian (no), Polish (pl), Portuguese (pt), Romanian (ro), Slovak (sk), Somali (so), Spanish (es), Swahili (sw), Swedish (sv), Turkish (tr), and Zulu (zu).
In some cases, such as smaller sites, you may wish to omit these defaults or use your own set. You can do this on the command line:
terminal
staticsearch -W
# or
staticsearch --ignorestopdefault
in an environment variable:
example .env
# StaticSearch environment variables
STOPWORDS_DEFAULT=false
or using the Node.js API:
index.js example
// run indexer
import { staticsearch } from 'staticsearch';
staticsearch.stopWordsDefault = false;
await staticsearch.index();
Miscellaneous updates #
Minor changes include:
- Index files are generated to a
searchsubdirectory of the build directory unless overridden. - The search result scrollbar thumbs now use the
--staticsearch-color-fore2color. - Words with valid technical meanings have been removed from the English stop word list.
- Slug paths generated on Windows devices now use
/rather than\.
Get started #
The StaticSearch documentation provides a quick start guide, and details about the indexer, web component, bind module, and JavaScript API.
StaticSearch works well with Publican sites. The Publican documentation provides a quick start guide, a detailed set-up guide, API references, and common recipes you can use and adapt for your own projects.