Full-text Search Suggestion AEM 6.0
- February 20, 2016
- 8 replies
- 5047 views
Hi all,
I am trying to achieve predictive search (suggestions) on AEM 6.0 with Apache Jackrabbit Oak 1.0.22. Following OAK documentation, since Oak 1.0.15, we are able to find suggestions for a given query by using Apache Lucene. Moreover, I have created an extra index to able full-text search with suggestion on the jcr:description property (see picture):
I have a page whose jcr:description is "This is my query word within the page description"
My back-end code is something like that:
QueryManager qm = session.getWorkspace().getQueryManager();
String query = "SELECT [rep:suggest()] FROM nt:base WHERE [jcr:path] = '/content/myproject' AND SUGGEST('query')";
Query searchQuery = qm.createQuery(query, Query.SQL);
RowIterator it = searchQuery.execute().getRows();
I get no results and the logs shows: org.apache.jackrabbit.oak.query.ast.SuggestImpl No full-text index was found that can process the condition suggest([nt:base], cast('query' as string))
However, if I query like that:
queryMap.put("fulltext", "query");
queryMap.put("path", "/content/myproject");
final QueryBuilder queryBuilder = resourceResolver.adaptTo(QueryBuilder.class);
return queryBuilder.createQuery(PredicateGroup.create(queryMap), session);
I get result -> the page with the description.
Could anybody give me a clue about why the suggestion query is not working? Why doesn't OAK find full-text indexes if there are two of them, the OOTB 'lucene' and the custom one 'lucene-suggestion' created by me?
Many thanks, Salvador.