Expand my Community achievements bar.

SOLVED

Search suggestion in aem 6.5

Avatar

Level 4

Hi,

 

I want to use search suggestion for all the pages under content node.

How do i achieve this? i have tried using querybuilder but i didn't get the search words similar to what user has input in the search field rather it shows the path where the text exists. Please anyone can help me with this?

 

Thanks,

Mahesh

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 4

@Anmol_Bhardwaj 

 

Thanks for the solution but i already solved this using above SQL2 query where i was passing dynamic values in query. So it worked i had to tweak the query a little.

 

Really appreciate your help.

 

Thanks,

Mahesh

View solution in original post

8 Replies

Avatar

Level 4

Hi Anmol,

 

I have tried that way but i am not able to create any custom node under Oak:index.

Attaching the screenshot and error logs here.

 

smahesh_0-1657780645400.png

 

 

14.07.2022 12:04:49.651 *ERROR* [qtp1534022781-1847] org.apache.felix.http.jetty Exception while processing request to /crx/server/crx.default/jcr:root (java.lang.UnsupportedOperationException: This builder is read-only.)
java.lang.UnsupportedOperationException: This builder is read-only.
at org.apache.jackrabbit.oak.spi.state.ReadOnlyBuilder.unsupported(ReadOnlyBuilder.java:44) [org.apache.jackrabbit.oak-store-spi:1.22.9]
at org.apache.jackrabbit.oak.spi.state.ReadOnlyBuilder.setChildNode(ReadOnlyBuilder.java:105) [org.apache.jackrabbit.oak-store-spi:1.22.9]
at org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition.updateDefinition(IndexDefinition.java:1433) [org.apache.jackrabbit.oak-lucene:1.22.9]
at org.apache.jackrabbit.oak.plugins.index.search.spi.editor.FulltextIndexEditorContext.<init>(FulltextIndexEditorContext.java:114) [org.apache.jackrabbit.oak-lucene:1.22.9]
at org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorContext.<init>(LuceneIndexEditorContext.java:48) [org.apache.jackrabbit.oak-lucene:1.22.9]
at org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider.getIndexEditor(LuceneIndexEditorProvider.java:236) [org.apache.jackrabbit.oak-lucene:1.22.9]
at org.apache.jackrabbit.oak.plugins.index.CompositeIndexEditorProvider.getIndexEditor(CompositeIndexEditorProvider.java:73) [org.apache.jackrabbit.oak-core:1.22.9]
at org.apache.jackrabbit.oak.plugins.index.WhiteboardIndexEditorProvider.getIndexEditor(WhiteboardIndexEditorProvider.java:49) [org.apache.jackrabbit.oak-core:1.22.9]
at org.apache.jackrabbit.oak.plugins.index.IndexUpdate.collectIndexEditors(IndexUpdate.java:282) [org.apache.jackrabbit.oak-core:1.22.9]
at org.apache.jackrabbit.oak.plugins.index.IndexUpdate.enter(IndexUpdate.java:164) [org.apache.jackrabbit.oak-core:1.22.9]
at org.apache.jackrabbit.oak.spi.commit.VisibleEditor.enter(VisibleEditor.java:53) [org.apache.jackrabbit.oak-store-spi:1.22.9]
at org.apache.jackrabbit.oak.spi.commit.EditorDiff.process(EditorDiff.java:48) [org.apache.jackrabbit.oak-store-spi:1.22.9]
at org.apache.jackrabbit.oak.spi.commit.EditorHook.processCommit(EditorHook.java:54) [org.apache.jackrabbit.oak-store-spi:1.22.9]
at org.apache.jackrabbit.oak.spi.commit.CompositeHook.processCommit(CompositeHook.java:60) [org.apache.jackrabbit.oak-store-spi:1.22.9]
at org.apache.jackrabbit.oak.spi.commit.CompositeHook.processCommit(CompositeHook.java:60) [org.apache.jackrabbit.oak-store-spi:1.22.9]
at org.apache.jackrabbit.oak.segment.scheduler.Commit.apply(Commit.java:99) [org.apache.jackrabbit.oak-segment-tar:1.22.9]
at org.apache.jackrabbit.oak.segment.scheduler.LockBasedScheduler.execute(LockBasedScheduler.java:299) [org.apache.jackrabbit.oak-segment-tar:1.22.9]
at org.apache.jackrabbit.oak.segment.scheduler.LockBasedScheduler.schedule(LockBasedScheduler.java:270) [org.apache.jackrabbit.oak-segment-tar:1.22.9]
at org.apache.jackrabbit.oak.segment.SegmentNodeStore.merge(SegmentNodeStore.java:211) [org.apache.jackrabbit.oak-segment-tar:1.22.9]
at org.apache.jackrabbit.oak.core.MutableRoot.commit(MutableRoot.java:251) [org.apache.jackrabbit.oak-core:1.22.9]
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.commit(SessionDelegate.java:346) [org.apache.jackrabbit.oak-jcr:1.22.9]
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.save(SessionDelegate.java:493) [org.apache.jackrabbit.oak-jcr:1.22.9]
at org.apache.jackrabbit.oak.jcr.session.SessionImpl$8.performVoid(SessionImpl.java:424) [org.apache.jackrabbit.oak-jcr:1.22.9]
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.performVoid(SessionDelegate.java:273) [org.apache.jackrabbit.oak-jcr:1.22.9]
at org.apache.jackrabbit.oak.jcr.session.SessionImpl.save(SessionImpl.java:421) [org.apache.jackrabbit.oak-jcr:1.22.9]
at com.adobe.granite.repository.impl.CRX3SessionImpl.save(CRX3SessionImpl.java:208) [com.adobe.granite.repository:1.6.28.CQ650-B0001]
at org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet.processDiff(JcrRemotingServlet.java:562) [org.apache.sling.jcr.davex:1.3.10]
at org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet.doPost(JcrRemotingServlet.java:427) [org.apache.sling.jcr.davex:1.3.10]
at org.apache.jackrabbit.webdav.server.AbstractWebdavServlet.execute(AbstractWebdavServlet.java:410) [org.apache.jackrabbit.jackrabbit-webdav:2.20.2]
at org.apache.jackrabbit.webdav.server.AbstractWebdavServlet.service(AbstractWebdavServlet.java:316) [org.apache.jackrabbit.jackrabbit-webdav:2.20.2]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) [org.apache.felix.http.servlet-api:1.1.2]
at org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:123) [org.apache.felix.http.jetty:4.1.10]
at org.apache.felix.http.base.internal.dispatch.InvocationChain.doFilter(InvocationChain.java:86) [org.apache.felix.http.jetty:4.1.10]
at com.adobe.granite.cors.impl.CORSFilter.doFilter(CORSFilter.java:88) [com.adobe.granite.cors:1.0.10.CQ650-B0002]
at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:142) [org.apache.felix.http.jetty:4.1.10]
at org.apache.felix.http.base.internal.dispatch.InvocationChain.doFilter(InvocationChain.java:81) [org.apache.felix.http.jetty:4.1.10]
at com.adobe.granite.license.impl.LicenseCheckFilter.doFilter(LicenseCheckFilter.java:308) [com.adobe.granite.license:1.2.10]
at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:142) [org.apache.felix.http.jetty:4.1.10]
at org.apache.felix.http.base.internal.dispatch.InvocationChain.doFilter(InvocationChain.java:81) [org.apache.felix.http.jetty:4.1.10]
at org.apache.sling.i18n.impl.I18NFilter.doFilter(I18NFilter.java:131) [org.apache.sling.i18n:2.5.14]
at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:142) [org.apache.felix.http.jetty:4.1.10]
at org.apache.felix.http.base.internal.dispatch.InvocationChain.doFilter(InvocationChain.java:81) [org.apache.felix.http.jetty:4.1.10]
at org.apache.felix.http.base.internal.dispatch.Dispatcher$1.doFilter(Dispatcher.java:146) [org.apache.felix.http.jetty:4.1.10]
at org.apache.felix.http.base.internal.whiteboard.WhiteboardManager$2.doFilter(WhiteboardManager.java:1002) [org.apache.felix.http.jetty:4.1.10]
at com.adobe.granite.cors.impl.CORSFilter.doFilter(CORSFilter.java:88) [com.adobe.granite.cors:1.0.10.CQ650-B0002]
at org.apache.felix.http.base.internal.handler.PreprocessorHandler.handle(PreprocessorHandler.java:137) [org.apache.felix.http.jetty:4.1.10]
at org.apache.felix.http.base.internal.whiteboard.WhiteboardManager$2.doFilter(WhiteboardManager.java:1008) [org.apache.felix.http.jetty:4.1.10]
at com.adobe.granite.auth.oauth.impl.OAuthCallbackFilter.doFilter(OAuthCallbackFilter.java:69) [com.adobe.granite.auth.oauth:1.7.2]
at org.apache.felix.http.base.internal.handler.PreprocessorHandler.handle(PreprocessorHandler.java:137) [org.apache.felix.http.jetty:4.1.10]
at org.apache.felix.http.base.internal.whiteboard.WhiteboardManager$2.doFilter(WhiteboardManager.java:1008) [org.apache.felix.http.jetty:4.1.10]
at com.adobe.granite.auth.ims.impl.IMSClusterExchangeTokenPreprocessor.doFilter(IMSClusterExchangeTokenPreprocessor.java:281) [com.adobe.granite.auth.ims:1.3.12.CQ650-B0014]
at org.apache.felix.http.base.internal.handler.PreprocessorHandler.handle(PreprocessorHandler.java:137) [org.apache.felix.http.jetty:4.1.10]
at org.apache.felix.http.base.internal.whiteboard.WhiteboardManager$2.doFilter(WhiteboardManager.java:1008) [org.apache.felix.http.jetty:4.1.10]
at org.apache.sling.security.impl.ReferrerFilter.doFilter(ReferrerFilter.java:326) [org.apache.sling.security:1.1.16]
at org.apache.felix.http.base.internal.handler.PreprocessorHandler.handle(PreprocessorHandler.java:137) [org.apache.felix.http.jetty:4.1.10]
at org.apache.felix.http.base.internal.whiteboard.WhiteboardManager$2.doFilter(WhiteboardManager.java:1008) [org.apache.felix.http.jetty:4.1.10]
at org.apache.felix.http.sslfilter.internal.SslFilter.doFilter(SslFilter.java:97) [org.apache.felix.http.sslfilter:1.2.6]
at org.apache.felix.http.base.internal.handler.PreprocessorHandler.handle(PreprocessorHandler.java:137) [org.apache.felix.http.jetty:4.1.10]
at org.apache.felix.http.base.internal.whiteboard.WhiteboardManager$2.doFilter(WhiteboardManager.java:1008) [org.apache.felix.http.jetty:4.1.10]
at org.apache.felix.http.base.internal.whiteboard.WhiteboardManager.invokePreprocessors(WhiteboardManager.java:1012) [org.apache.felix.http.jetty:4.1.10]
at org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:91) [org.apache.felix.http.jetty:4.1.10]
at org.apache.felix.http.base.internal.dispatch.DispatcherServlet.service(DispatcherServlet.java:49) [org.apache.felix.http.jetty:4.1.10]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) [org.apache.felix.http.servlet-api:1.1.2]
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:550) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1435) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1350) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:191) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.server.Server.handle(Server.java:516) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:383) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:882) [org.apache.felix.http.jetty:4.1.10]
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1036) [org.apache.felix.http.jetty:4.1.10]
at java.base/java.lang.Thread.run(Unknown Source)

 

 

Avatar

Community Advisor

I am able to create custom indexes under /oak:index. ( I am using 6.5.13)

 

Are you using AEM 6.5 or AEMaaCS.

If you're using the latter, there are couple of open issues for this.

Workaround is :
https://wcm-io.atlassian.net/wiki/spaces/WCMIO/pages/2471198721/OSGi+bundles+with+Sling-Initial-Cont...

 

Avatar

Level 4

Hi Anmol,

 

This is kind of static query(SELECT [rep:suggest()] FROM [nt:unstructured] WHERE SUGGEST('te') AND ISDESCENDANTNODE('/content/sampledata'))

in my case when i type any word in the search field it should display the property value like jcr:title of pages but in query we have to give the exact term to display the results. How do i make it dynamic? please could you suggest some solution.

 

Thanks,

Mahesh

Avatar

Community Advisor

Hi @smahesh ,

 

There is a faster way for this through XPath query by using the fullText.

You can use wildcard in fullText and get similar results and/or results containing the phrase we pass. By default, fulltext checks jcr:title so you wuold only need to pass the path under which you need to search. You also wouldn't need any custom indexes for the same.

 

Query : 

path=/content/

fulltext= *se*

 

Avatar

Correct answer by
Level 4

@Anmol_Bhardwaj 

 

Thanks for the solution but i already solved this using above SQL2 query where i was passing dynamic values in query. So it worked i had to tweak the query a little.

 

Really appreciate your help.

 

Thanks,

Mahesh

Avatar

Level 1

Hi @smahesh ,

 

Can you please explain how you were able to dynamic values in above SQL2 query(instead of fixed keyword like test).

 

 

Avatar

Level 4

Hi @VivekFirke ,

 

Please pass the keyword like this(' "+keyword+ " ') in the query. It will work for sure.

 

Thanks,

Mahesh