Details
-
New Feature
-
Resolution: Outdated
-
Minor
-
None
-
None
-
None
-
None
-
-
Empty show more show less
Description
for workspace.xml:
<param name="spellCheckerClass" value="org.apache.jackrabbit.core.query.lucene.spell.LuceneSpellChecker$OneMinuteRefreshInterval" />
code for the template:
<%
String q = request.getParameter("query");
Query query = MgnlContext.getWebContext().getQueryManager("website")
.createQuery("/jcr:root[rep:spellcheck('"+q+"')]/(rep:spellcheck())", Query.XPATH);
RowIterator rows = ((QueryResultImpl)query.execute()).getJcrResult().getRows();
// the above query will always return one row no matter what string we check
Row r = rows.nextRow();
// get the result of the spell checking
Value v = r.getValue("rep:spellcheck()");
if (v == null) {
// no suggestion returned, the spelling is correct or the spell checker
// does not know how to correct it.
} else {
String suggestion = v.getString();
out.write("Did you mean <b>" + suggestion + "</b>?");
}
%>