From commits-return-4765-apmail-jackrabbit-commits-archive=jackrabbit.apache.org@jackrabbit.apache.org Wed Oct 24 12:56:54 2007 Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 15044 invoked from network); 24 Oct 2007 12:56:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Oct 2007 12:56:54 -0000 Received: (qmail 41808 invoked by uid 500); 24 Oct 2007 12:56:42 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 41730 invoked by uid 500); 24 Oct 2007 12:56:41 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 41721 invoked by uid 99); 24 Oct 2007 12:56:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Oct 2007 05:56:41 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.130] (HELO eos.apache.org) (140.211.11.130) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Oct 2007 12:56:53 +0000 Received: from eos.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id B0E0959A07 for ; Wed, 24 Oct 2007 12:56:33 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki To: commits@jackrabbit.apache.org Date: Wed, 24 Oct 2007 12:56:33 -0000 Message-ID: <20071024125633.3670.22825@eos.apache.org> Subject: [Jackrabbit Wiki] Update of "SpellChecker" by MarcelReutegger X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Jackrabbit Wiki" for change notification. The following page has been changed by MarcelReutegger: http://wiki.apache.org/jackrabbit/SpellChecker New page: The lucene based query handler implementation supports a pluggable spell checker mechanism. Per default spell checking is not available and you have to configure it first. See parameter {{{spellCheckerClass}}} on page ["Search"]. Jackrabbit currently provides an implementation in the sandbox area, which uses the [http://wiki.apache.org/jakarta-lucene/SpellChecker lucene-spellchecker] contrib. The dictionary is derived from the fulltext indexed content of the workspace and updated periodically. You can configure the refresh interval by picking one of the available inner classes of {{{org.apache.jackrabbit.core.query.lucene.spell.LuceneSpellChecker}}}: * One``Minute``Refresh``Interval * Five``Minutes``Refresh``Interval * Thirty``Minutes``Refresh``Interval * One``Hour``Refresh``Interval * Six``Hours``Refresh``Interval * Twelve``Hours``Refresh``Interval * One``Day``Refresh``Interval E.g. if you want a refresh interval of six hours the class name is: {{{org.apache.jackrabbit.core.query.lucene.spell.LuceneSpellChecker$SixHoursRefreshInterval}}}. If you use {{{org.apache.jackrabbit.core.query.lucene.spell.LuceneSpellChecker}}} the refresh interval will be one hour. The spell checker dictionary is stored as a lucene index under /index/spellchecker. If it does not exist, a background thread will create it on startup. Similarly the dictionary refresh is also done in a background thread to not block regular queries. == How do I use it? == You can spell check a fulltext statement either with an XPath or a SQL query: {{{ // rep:spellcheck('jackrabit') will always evaluate to true Query query = qm.createQuery("/jcr:root[rep:spellcheck('jackrabit')]/(rep:spellcheck())", Query.XPATH); RowIterator rows = query.execute().getRows(); // the above query will always return the root node 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(); } }}} And the same using SQL: {{{ // SPELLCHECK('jackrabit') will always evaluate to true Query query = qm.createQuery("SELECT rep:spellcheck() FROM nt:base WHERE jcr:path = '/' AND SPELLCHECK('jackrabit')", Query.SQL); RowIterator rows = query.execute().getRows(); // the above query will always return the root node 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(); } }}}