Expand my Community achievements bar.

Create Smart Collections Programmatically

Avatar

Community Advisor

Hello,

 

How we can create Smart collections programmatically?

If you can provide a code snippet, that would be helpful.

Thanks.

@kautuk_sahni @arunpatidar 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

5 Replies

Avatar

Community Advisor

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/omn...

 

Hope this helps.

 

Thanks

Narendra

 

 

Avatar

Community Advisor

Hi @narendragandhi 

 

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

Avatar

Administrator

@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

Avatar

Community Advisor

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

Avatar

Community Advisor

@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.

 

narendragandhi_0-1709184442512.png

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

 

Thanks

Narendra