0
votes

Spell check is not working in AEM 6.1 even after creating the suggested indexes as specified in --

https://docs.adobe.com/docs/en/aem/6-1/deploy/platform/queries-and-indexing.html and

https://jackrabbit.apache.org/oak/docs/query/lucene.html

As per the docs spellcheck has been implemented in OAK since versions 1.1.17 and 1.0.13. My OAK version is 1.22 so it should work.The AEM version is 6.1.0.20150507

Created an index like -

/oak:index/lucene-spellcheck
  - jcr:primaryType = "oak:QueryIndexDefinition"
  - compatVersion = 2
  - type = "lucene"
  - async = "async"
  + indexRules
    - jcr:primaryType = "nt:unstructured"
    + nt:base
      + properties
        - jcr:primaryType = "nt:unstructured"
        + jcr:title
          - propertyIndex = true
          - analyzed = true
          - useInSpellcheck = true

I get zero results when I run this query using CRX-DE's query tool as well as using query manager from a jsp.

SELECT [rep:spellcheck()] FROM nt:base WHERE [jcr:path] = '/content/abc' AND SPELLCHECK('tetspage')

('testpage' is a page; misspelled it as 'tetspage')

Running this query as mentioned in the docs

SELECT [rep:spellcheck()] FROM nt:base WHERE [jcr:path] = '/' AND SPELLCHECK('jackrabit')

returns a single node.

Am I doing anything wrong; is this index working in anyone's AEM 6.1 ?

2

2 Answers

1
votes

This query works for me

SELECT [rep:spellcheck()] FROM [nt:base] WHERE SPELLCHECK('tetspage') AND ISDESCENDANTNODE('/content/abc')
0
votes

I had a similar problem with a "rep:suggest()" query, instead of a "rep:spellcheck()", but maybe the solution works for you.

When I tried the query in the CRX DE directly, the result was a single node, and I couldn't see anything on that node. However, executing the query from my code I found out that the results of the query were stored as "rows". To process that "rows" I used this code, hope it helps you:

String sql = "SELECT [rep:suggest()] FROM cq:PageContent WHERE ISDESCENDANTNODE('" + path + "/') AND SUGGEST('" + text + "')";
Query q = qm.createQuery(sql, Query.SQL);

List<String> results = Lists.newArrayList();  // <--- Actual query results
RowIterator it = q.execute().getRows();
while (it.hasNext()) {
    Row row = it.nextRow();
    results.add(row.getValue("rep:suggest()").getString());
}