Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-2708

Implement the jackrabbit spellchecker for the fulltext search

    XMLWordPrintable

Details

    • New Feature
    • Resolution: Outdated
    • Minor
    • None
    • None
    • None
    • None

    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>?");
      }
      %>

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              pbaerfuss Philipp Bärfuss
              tomwespi Tom Wespi
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: