Create Smart Collections Programmatically | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

narendragandhi
Community Advisor
Community Advisor
February 28, 2024

Hi @iamnjain 

 

You can use the OmniSearchService API to create smart collections programmatically. Here is the API documentation - https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/adobe/granite/omnisearch/api/core/OmniSearchService.html#createOrUpdateSavedSearch-org.apache.sling.api.resource.ResourceResolver-java.util.Map-

 

Hope this helps.

 

Thanks

Narendra

 

 

iamnjain
Community Advisor
iamnjainCommunity AdvisorAuthor
Community Advisor
February 28, 2024

Hi @narendragandhi 

 

Can you please provide a code example as well?
This is new to me, so I am asking 🙂

kautuk_sahni
Community Manager
Community Manager
February 28, 2024

@iamnjain Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni
iamnjain
Community Advisor
iamnjainCommunity AdvisorAuthor
Community Advisor
February 28, 2024

@kautuk_sahniIf anyone can provide a working code snippet, that would be helpful.

narendragandhi
Community Advisor
Community Advisor
February 29, 2024

@iamnjain Actually instead of recreating the servlet, you can just make POST request to the existing servlet which is being used -

 

Servlet Path - http://localhost:4502/libs/granite/omnisearch/savedsearch

You can get the request parameters and header details by manually creating a collection in your AEM instance and then search for 'savedSearch' in network tab of Chrome Developer tools.

 

Can you also provide details on how you are planning to invoke the smart collections creation ?

 

Thanks

Narendra