This documentation provides instructions on how to use the Project Endings staticSearch Generator to provide a fully-functional search ‘engine’ to your website without any dependency on server-side code such as a database.
Below are some of the most common things you might want to do using staticSearch:
How do I get staticSearch to ignore large chunks of my document? | Any element with a weight of 0 is ignored completely by the indexer, so add a <rule> for the element. So to ignore all elements with the class ignoreThisElement, you could do something like:
<rule weight="0"
match="div[contains-token(@class,'ignoreThisElement')"/> |
How do I get staticSearch to ignore small inline bits and not have them in the KWIC? | As above, you can use a <rule> with an weight=0 |
How do I get staticSearch to ignore an element, but retain its text in the KWIC? | Here, you'll want to use the <exclude> function, which excludes the element from indexing, but doesn't remove it from the
document itself. So, if you wanted to exclude all keyboard entry items (<xh:kbd>), but still have them in the KWIC, you could do something like:
<exclude match="kbd"
type="index"/> |
How can I get staticSearch to show debugging messages? | Switch <verbose> to true in the configuration file:
<config xmlns="http://hcmc.uvic.ca/ns/staticSearch">
<params> <!--....--> <verbose>true</verbose> <!--....--> </params> <!--Rules, etc--> </config> |
How can I get staticSearch to jump straight to a specific hit in the document from a search result? | The best way to do this is to ensure that <linkToFragmentId> is set to the true and that the input HTML contains ids at whatever level you think is most helpful. For instance, if possible, you could give each <xhtml:p> element an id, which would mean that each KWIC could be linked to the right paragraph in the input document. |
How can I get staticSearch to highlight the found text in a target document? | There are two approaches to this: you could implement a JavaScript solution as explained in Highlighting search hits on target pages, or you could turn on the <scrollToFragmentId> experimental feature supported by some Chromium-based browsers. The former requires some modification to your site pages to add some JavaScript, while the latter is non-standard and not really reliable or consistent. |
How do I prevent staticSearch from encountering out of memory errors? | If you are indexing a very large collection of files, you may need to provide ant
with additional memory by configuring the ANT_OPTS system property. To provide ant
with 4GB of memory, you could do something like so:
export ANT_OPTS="-Xmx4g"; ant -DssConfigFile=/absolute/path/to/your/config.xml⚓How much memory you can and should provide to Ant depends on your particular system and the size of the document collection. See Ant's documentation for some further examples and explanation. |