<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Activate AEM - Medium]]></title>
        <description><![CDATA[Welcome to our AEM-focused blog, dedicated to empowering AEM technologists with our experience at Bounteous. Dive into a treasure trove of how-to articles, with our comprehensive insights and step-by-step tutorials, for beginners and seasoned AEM vets alike. - Medium]]></description>
        <link>https://medium.com/activate-aem?source=rss----f73c4ff1649e---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Activate AEM - Medium</title>
            <link>https://medium.com/activate-aem?source=rss----f73c4ff1649e---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 19:05:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/activate-aem" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Open links in new tab with Section metadata — EDS]]></title>
            <link>https://medium.com/activate-aem/open-links-in-new-tab-with-section-metadata-eds-0c2c09ee2e4c?source=rss----f73c4ff1649e---4</link>
            <guid isPermaLink="false">https://medium.com/p/0c2c09ee2e4c</guid>
            <category><![CDATA[edge-delivery-services]]></category>
            <category><![CDATA[edgedeliverycustomization]]></category>
            <category><![CDATA[eds-articles]]></category>
            <category><![CDATA[adobe-eds]]></category>
            <category><![CDATA[aem-eds]]></category>
            <dc:creator><![CDATA[Ashwini Sathe]]></dc:creator>
            <pubDate>Sat, 11 Jan 2025 00:32:01 GMT</pubDate>
            <atom:updated>2025-01-11T00:32:00.801Z</atom:updated>
            <content:encoded><![CDATA[<h3>Open links in new tab with Section metadata — EDS</h3><p>Edge delivery services with document-based authoring currently do not allow for the inclusion of target attributes for hyperlinks or buttons. Since hyperlinks and buttons are generated from default content, there is no dedicated block for these elements within the EDS codebase, which limits customization options. Many websites feature external links that ideally should open in a new tab. This functionality enables users to explore the external content while keeping the original page open in the previous tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SDLPNABoAlpyyLaLdBrGyQ.png" /></figure><p><strong>Use Case</strong></p><p>Imagine a scenario in which your EDS site contains links or buttons that direct users to external sites. Currently, when a user clicks on these links, they open in the same tab, causing the loss of the original page. By configuring these external links to open in a new tab, users can maintain access to the source page while exploring the external content.</p><p>In this tutorial, we will explore how to configure links to open in a new tab using Section Metadata.</p><p>The section block serves as a default content type, but by utilizing Section Metadata, we can incorporate customized attributes and styles to enhance the section block’s appearance and functionality.</p><p>To ensure consistent link behavior within sections, you can apply metadata at the section level. When this approach is implemented, all links within a designated section will function as external links, opening in new tabs by default. However, if certain links need to remain internal, you’ll need to strategically divide your content into separate sections and apply the appropriate metadata to each section.</p><p><strong>Steps for implementation:</strong></p><ol><li>Add the following code for the section metadata in aem.js:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IdOj7Uyq-gjOiAGQs68Zaw.png" /></figure><p>2. Now navigate to the document and incorporate the section metadata as illustrated below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*53AA2YMWc2av8Cyu0VdNYg.png" /></figure><p>For mixed link behavior requirements, consider organizing your content into distinct sections with their respective metadata configurations. This structured approach allows for precise control over link functionality throughout your document as illustrated below.</p><p>Consider the scenario below where the first link is pointing to a page within the same site that means internal link while the other two links are pointing to different site (external links).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*04xdjrc6qhNRI82P58RCQg.png" /></figure><p>To achieve this, we can split the content into two sections as illustrated below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U3CrUuus89vElBH87WSUxw.png" /></figure><p>Note: If we don’t provide a section metadata the link will be treated as an internal link opening it in same tab. Sections will be separated by a horizontal line or three hyphens ( — -)</p><p><strong>Conclusion:</strong></p><p>The document outlines constraints of Edge Delivery Services (EDS) regarding hyperlink and button customization, especially the challenge of setting target attributes for external links in document-based authoring. It emphasizes the importance of allowing these links to open in a new tab, thereby enabling users to retain access to the original page while exploring external content. A practical use case and tutorial demonstrate how to configure links to open in a new tab using Section Metadata, highlighting enhancements in functionality and visual appeal within the EDS codebase.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0c2c09ee2e4c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/activate-aem/open-links-in-new-tab-with-section-metadata-eds-0c2c09ee2e4c">Open links in new tab with Section metadata — EDS</a> was originally published in <a href="https://medium.com/activate-aem">Activate AEM</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Asset Share Commons Login Integration]]></title>
            <link>https://medium.com/activate-aem/asset-share-commons-login-integration-8202df6fbf52?source=rss----f73c4ff1649e---4</link>
            <guid isPermaLink="false">https://medium.com/p/8202df6fbf52</guid>
            <category><![CDATA[aem-integration]]></category>
            <category><![CDATA[asclogin]]></category>
            <category><![CDATA[aem-assets]]></category>
            <category><![CDATA[aem]]></category>
            <category><![CDATA[asset-share-commons]]></category>
            <dc:creator><![CDATA[Balaji Srinivasan]]></dc:creator>
            <pubDate>Fri, 20 Dec 2024 12:02:29 GMT</pubDate>
            <atom:updated>2024-12-20T12:02:28.985Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yekEa3-WnKK0CuhozK_-UA.png" /></figure><p>Asset Share Commons (ASC) is a modern, open-source implementation for Asset Share, designed specifically for Adobe Experience Manager as a Cloud Service. Asset Share Commons enables users to search, view, download, and share assets. Built as a standard AEM site with an open-source implementation, it offers extensive integration and customization options to meet specific needs. For example, it can be tailored to allow sharing multiple renditions of assets and integrated with any authentication provider. You can learn more about Asset Share Commons and the features available in it from the <a href="https://opensource.adobe.com/asset-share-commons/">official documentation</a>. This article covers the integration of login functionality with ASC using the Curity Identity Server.</p><p>Curity Identity Server is a comprehensive identity and access management (IAM) solution designed to deliver secure authentication, authorization, and API protection for modern applications. It supports protocols like OAuth 2.0 and OpenID Connect, enabling features such as single sign-on (SSO) and multi-factor authentication (MFA). The server also includes user registration functionality, allowing new users to create accounts. Furthermore, it offers an HTML-Form Based Authenticator, which enables the creation of custom login forms, providing flexibility in the authentication process.</p><p>This article outlines the necessary configuration changes within Adobe Experience Manager (AEM) and the setup of a Curity sandbox environment to enable thorough end-to-end testing of the login process. Additionally, it covers the user group configuration and associated permissions to manage access to and restrictions on assets within the ASC.</p><p><strong>Curity IDP Setup:</strong></p><p>In Curity Sandbox, Go to Token Service and create a client for ASC.</p><figure><img alt="Clients available in Curity" src="https://cdn-images-1.medium.com/max/1024/1*Zs5ZlU12NTEKvZ22rqUUuQ.png" /></figure><p>Edit the ASC Client and Click on capabilities. Add Code Flow and click Next.</p><figure><img alt="Capabilities within a client in Curity" src="https://cdn-images-1.medium.com/max/800/1*3-ap6FRk5UvKP2nGi9me6A.jpeg" /></figure><p>Add the Redirect URIs to whitelist. Append /callback/j_security_check to the Page URL and add it to the Redirect URIs list.</p><figure><img alt="Redirect URIs for the Client" src="https://cdn-images-1.medium.com/max/1024/1*ELCRmUEneKeJX1XpHk61fA.png" /></figure><p>In the Authentication method, select secret and generate it. Copy the secret value and store it somewhere as this will be required in the AEM Configuration.</p><figure><img alt="Authentication Method for the Client" src="https://cdn-images-1.medium.com/max/1024/1*gjkMh1eaSJk7mEzT4i2NZw.png" /></figure><p>Select html-form as the User Authentication method.</p><figure><img alt="User Authentication method for the login" src="https://cdn-images-1.medium.com/max/1024/1*DTX1Bf3wTuDsVY9ywpYJMg.png" /></figure><p>Add the scopes under Authorization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j2fEE5zLcyvn0HUPVyNFmw.png" /></figure><p>Add the Client name (for example, ASC) and note it down as it is needed in AEM Configuration. Commit the changes.</p><p><strong>AEM Configurations:</strong></p><p>The integration process involves several key configurations within AEM, including the following:</p><ul><li>Configure the Service User</li><li>Setup Custom OAuth Provider</li><li>OSGi Configurations</li><li>Cloud Environment Variables</li></ul><p><strong>Configure the Service User:</strong></p><p>Create a service user and assign the required permissions to manage user creation. This can be accomplished by using the Repo Init script and configuring the service user mappings.</p><p>org.apache.sling.jcr.repoinit.RepositoryInitializer-service-user.cfg.json</p><pre>{ <br> &quot;scripts&quot;: [ <br> &quot;create service user oauth-service&quot;, <br> &quot;set ACL for oauth-service\n allow jcr:all on /home\nend&quot; <br> ] <br>}</pre><p>org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended~oauth-service.cfg.json</p><pre>{ <br> &quot;service.ranking&quot;:&quot;0&quot;, <br> &quot;user.mapping&quot;:[ <br> &quot;mycompany.core:oauth-service=oauth-service&quot; <br> ] <br>}</pre><p>mycompany.core should be the Symbolic name from core bundle.</p><p><strong>Setup Custom OAuth Provider:</strong></p><p>The implementation of a custom provider involves the following steps:</p><p>Create an Api class CurityOAuth2Api.java</p><pre>package com.mycompany.aem.platform.core.auth; <br><br>import com.mycompany.aem.platform.core.auth.impl.CurityOAuth2ServiceImpl; <br>import org.scribe.builder.api.DefaultApi20; <br>import org.scribe.extractors.AccessTokenExtractor; <br>import org.scribe.model.OAuthConfig; <br>import org.scribe.oauth.OAuthService; <br>import java.util.Map; <br>import java.util.concurrent.ConcurrentHashMap; <br><br>/** <br>* CurityOAuth2Api is a custom implementation of the OAuth 2.0 API for integrating with the Curity identity server. <br>* It provides methods for constructing the authorization URL, retrieving the access token endpoint, and extracting <br>* access tokens from OAuth responses. <br>* This class extends the DefaultApi20 class from the Scribe library to manage <br>* OAuth2 flows such as authorization code grant and token exchange. <br>*/ <br><br>public class CurityOAuth2Api extends DefaultApi20 { <br><br>    String baseUrl; <br>    private final Map&lt;String, String&gt; tokenAndVerifierMap = new ConcurrentHashMap&lt;&gt;(); <br><br>    public CurityOAuth2Api(String baseUrl) { <br>        this.baseUrl = baseUrl; <br>    } <br><br>    @Override <br>    public String getAccessTokenEndpoint() { <br>        return this.baseUrl + &quot;/oauth-token&quot;; <br>    }<br><br>    @Override <br>    public AccessTokenExtractor getAccessTokenExtractor() { <br>        return new CurityOauth2TokenExtractor(); <br>    } <br><br>    @Override <br>    public String getAuthorizationUrl(OAuthConfig oAuthConfig) { <br>        String endpoint = this.baseUrl +&quot;/oauth-authorize?client_id=%s&amp;scope=openid profile email phone&amp;response_type=code&amp;redirect_uri=%s&quot;; <br>        return  String.format(endpoint,oAuthConfig.getApiKey(), oAuthConfig.getCallback()) ; <br>    } <br><br>    public OAuthService createService(OAuthConfig config) { <br>        return new CurityOAuth2ServiceImpl(this, config); <br>    } <br><br>} </pre><p>Add a Service class to get the Access token CurityOAuth2ServiceImpl.java</p><pre>package com.mycompany.aem.platform.core.auth.impl; <br><br>import org.scribe.builder.api.DefaultApi20; <br>import org.scribe.model.OAuthConfig; <br>import org.scribe.model.OAuthConstants; <br>import org.scribe.model.OAuthRequest; <br>import org.scribe.model.Response; <br>import org.scribe.model.Token; <br>import org.scribe.model.Verb; <br>import org.scribe.model.Verifier; <br>import org.scribe.oauth.OAuthService; <br>import java.util.Base64; <br><br>/** <br>* CurityOAuth2ServiceImpl is an implementation of the OAuthService interface, specifically designed for OAuth 2.0  <br>* integration with the Curity identity server. This service handles OAuth 2.0 operations such as obtaining  <br>* access tokens, signing requests, and constructing authorization URLs. <br>* <br>* Key responsibilities: <br>* - Handling the exchange of authorization codes for access tokens using the &quot;authorization_code&quot; grant type. <br>* - Signing OAuth requests with the obtained access tokens to authenticate API calls. <br>* - Generating the authorization URL for redirecting users to the Curity platform for authentication. <br>*/ <br><br>public class CurityOAuth2ServiceImpl implements OAuthService { <br><br>    private static final String VERSION = &quot;2.0&quot;; <br>    private final DefaultApi20 api; <br>    private final OAuthConfig config; <br><br>    public CurityOAuth2ServiceImpl(DefaultApi20 api, OAuthConfig config) { <br>        this.api = api; <br>        this.config = config; <br>    } <br> <br>    @Override <br>    public Token getRequestToken() { <br>        throw new UnsupportedOperationException(&quot;Unsupported operation, please use &#39;getAuthorizationUrl&#39; and redirect your users there&quot;); <br>    }<br> <br>    @Override <br>    public Token getAccessToken(Token token, Verifier verifier) { <br>        OAuthRequest request = new OAuthRequest(Verb.POST, api.getAccessTokenEndpoint()); <br>        request.addBodyParameter(OAuthConstants.CLIENT_ID, config.getApiKey()); <br>        request.addBodyParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret()); <br>        request.addBodyParameter(OAuthConstants.CODE, verifier.getValue()); <br>        request.addBodyParameter(OAuthConstants.REDIRECT_URI, config.getCallback()); <br>        request.addBodyParameter(&quot;grant_type&quot;, &quot;authorization_code&quot;); <br>        String authenticationHeader = config.getApiKey()+&quot;:&quot;+config.getApiSecret(); <br>        request.addHeader(&quot;Authorization&quot;,&quot;Basic &quot; + Base64.getEncoder().encodeToString(authenticationHeader.getBytes())); <br>        Response response = request.send(); <br>        return api.getAccessTokenExtractor().extract(response.getBody()); <br>    } <br><br>    @Override <br>    public void signRequest(Token accessToken, OAuthRequest oAuthRequest) { <br>        oAuthRequest.addHeader(&quot;Authorization&quot;, &quot;Bearer &quot; + accessToken.getToken()); <br>    } <br><br>    @Override <br>    public String getVersion() { <br>        return VERSION; <br>    }<br> <br>    @Override <br>    public String getAuthorizationUrl(Token token) { <br>        return api.getAuthorizationUrl(config); <br>    } <br><br>}</pre><p>Add a token extractor class CurityOauth2TokenExtractor.java</p><pre>package com.mycompany.aem.platform.core.auth; <br><br>import org.scribe.exceptions.OAuthException; <br>import org.scribe.extractors.AccessTokenExtractor; <br>import org.scribe.model.Token; <br>import org.scribe.utils.OAuthEncoder; <br>import org.scribe.utils.Preconditions; <br>import java.util.regex.Matcher; <br>import java.util.regex.Pattern; <br> <br>/** <br>* IdentityServerOauth2TokenExtractor is a custom implementation of the AccessTokenExtractor interface,  <br>* responsible for extracting OAuth 2.0 access tokens from a JSON response body returned by an identity server. <br>* This class specifically parses the response to retrieve the access token using a regular expression. <br>*/ <br><br>public class CurityOauth2TokenExtractor implements AccessTokenExtractor { <br> <br>    private static final String TOKEN_REGEX = &quot;access_token\&quot;:\&quot;([^\&quot;]+)&quot;; <br>    private static final String EMPTY_SECRET = &quot;&quot;; <br><br>    @Override <br>    public Token extract(String response) { <br>        Preconditions.checkEmptyString(response, <br>                &quot;Response body is incorrect. Can&#39;t extract a token from an empty string&quot;); <br>        Matcher matcher = Pattern.compile(TOKEN_REGEX).matcher(response); <br>        if (matcher.find()) { <br>            String token = OAuthEncoder.decode(matcher.group(1)); <br>            return new Token(token, EMPTY_SECRET, response); <br>        } else { <br>            throw new OAuthException(&quot;Response body is incorrect. Can&#39;t extract a token from this: &#39;&quot; + response + &quot;&#39;&quot;, <br>                    null); <br>        } <br>    } <br><br>} </pre><p>Create a Base Provider class</p><pre>package com.mycompany.aem.platform.core.auth.impl; <br><br>import com.adobe.granite.auth.oauth.Provider; <br>import com.adobe.granite.auth.oauth.ProviderType; <br>import com.adobe.granite.security.user.UserPropertiesService; <br>import com.google.gson.Gson; <br>import com.google.gson.JsonSyntaxException; <br>import org.apache.jackrabbit.api.security.user.Authorizable; <br>import org.apache.jackrabbit.api.security.user.User; <br>import org.apache.sling.api.SlingHttpServletRequest; <br>import org.apache.sling.api.resource.LoginException; <br>import org.apache.sling.api.resource.ResourceResolver; <br>import org.apache.sling.api.resource.ResourceResolverFactory; <br>import org.scribe.builder.api.Api; <br>import org.scribe.model.OAuthRequest; <br>import org.scribe.model.Response; <br>import org.scribe.model.Verb; <br>import org.slf4j.Logger; <br>import org.slf4j.LoggerFactory; <br><br>import javax.jcr.Node; <br>import javax.jcr.RepositoryException; <br>import javax.jcr.Session; <br>import java.io.IOException; <br>import java.util.HashMap; <br>import java.util.Map; <br> <br>/** <br>* OAuth2BaseProvider is an abstract implementation of the Provider interface for integrating OAuth 2.0-based authentication. <br>* It serves as a base class for specific OAuth2 providers, handling core <br>* OAuth operations like user creation, profile mapping, and access token management. <br>* <br>* Key responsibilities: <br>* - Provides methods for managing user profiles and extracting user details from OAuth2 responses. <br>* - Maps OAuth2 properties (such as given name, surname, email) to AEM user profile properties. <br>* - Facilitates retrieval of protected user data via OAuth2 requests. <br>* - Defines utility methods for handling OAuth tokens and user-related data, including custom mappings of OAuth <br>*   attributes to user profile paths. <br>*/ <br><br>abstract class OAuth2BaseProvider implements Provider  { <br><br>    private final Logger log = LoggerFactory.getLogger(getClass()); <br>    protected UserPropertiesService userPropertiesService;<br>    protected ResourceResolverFactory resourceResolverFactory; <br>    protected Api api;<br>    protected String id; <br>    protected String name; <br>    protected String profileUrl; <br>    public static final String USER_ADMIN = &quot;oauth-service&quot;; <br><br>    @Override <br>    public String getId() { <br>        return this.id; <br>    } <br><br>    @Override <br>    public String getName() { <br>        return this.name; <br>    } <br> <br>    @Override <br>    public ProviderType getType() { <br>        return ProviderType.OAUTH2; <br>    } <br><br>    @Override <br>    public Api getApi() { <br>        return this.api; <br>    } <br> <br>    //using token endpoint as the profile url <br>    @Override <br>    public String getDetailsURL() { <br>        return this.profileUrl; <br>    } <br><br>    @Override <br>    public String[] getExtendedDetailsURLs(String scope) { <br>        return new String[0]; <br>    } <br><br>    @Override <br>    public String[] getExtendedDetailsURLs(String scope, String userId, Map&lt;String, Object&gt; props) { <br>        return new String[0]; <br>    } <br><br>    public String mapProperty(String property) { <br>        if (&quot;http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname&quot;.equals(property)) <br>            return &quot;profile/givenName&quot;; <br>        if (&quot;http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname&quot;.equals(property)) <br>            return &quot;profile/familyName&quot;; <br>        if (&quot;http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress&quot;.equals(property)) <br>            return &quot;profile/email&quot;; <br>        return getPropertyPath(property); <br>    } <br><br>    @Override <br>    public String mapUserId(final String userId, final Map&lt;String, Object&gt; props) { <br>        return (String) props.get(getPropertyPath(&quot;name&quot;)); <br>    } <br><br>    /** <br>     * Called after a user is created by Granite <br>     * <br>     * @param user <br>     */ <br><br>    @Override <br>    public void onUserCreate(final User user) { <br>        Map&lt;String, Object&gt; serviceParams = new HashMap&lt;String, Object&gt;(); <br>        serviceParams.put(ResourceResolverFactory.SUBSERVICE, USER_ADMIN); <br>        try (ResourceResolver serviceUserResolver = this.resourceResolverFactory.getServiceResourceResolver(serviceParams)) { <br>            Session session = serviceUserResolver.adaptTo(Session.class); <br>            if (null != session) { <br>                getUserFromProps(user, session, userPropertiesService);<br>                if (session.isLive()) { <br>                    session.logout(); <br>                    session = null; <br>                } <br>            } <br>        } catch (final RepositoryException e) { <br>            log.error(&quot;onUserCreate: failed to copy profile properties to cq profile&quot;, e); <br>        } catch (LoginException e) { <br>            log.error(&quot;Unable to create service user resource resolver : &quot;, e); <br>        } <br>    } <br><br>    protected void getUserFromProps(User user, Session session, <br>                            UserPropertiesService userPropertiesService) throws RepositoryException { <br>        session.refresh(true); <br>        final Node userNode = session.getNode(userPropertiesService.getAuthorizablePath(user.getID())); <br>        final Node profNode = userNode.getNode(&quot;profile&quot;);<br> <br>        if (user.hasProperty(&quot;profile/givenName&quot;)) { <br>            String firstName = user.getProperty(&quot;profile/givenName&quot;)[0].getString(); <br>            profNode.setProperty(&quot;givenName&quot;, firstName); <br>        } <br><br>        if (user.hasProperty(&quot;profile/familyName&quot;)) { <br>            String lastName = user.getProperty(&quot;profile/familyName&quot;)[0].getString(); <br>            profNode.setProperty(&quot;familyName&quot;, lastName); <br>        } <br><br>        if (user.hasProperty(&quot;profile/email&quot;)) { <br>            String email = user.getProperty(&quot;profile/email&quot;)[0].getString(); <br>            profNode.setProperty(&quot;email&quot;, email); <br>        } <br>        session.save(); <br>        session.refresh(true); <br>    } <br><br>    protected String getPropertyPath(final String property) { <br>        return &quot;profile/&quot; + property; <br>    } <br><br>    @Override <br>    public String getUserFolderPath(String userId, String clientId, Map&lt;String, Object&gt; props) { <br>        StringBuilder sb = new StringBuilder(getId()); <br>        if (userId != null) <br>            sb.append(&quot;/&quot;).append(userId.substring(0, 4)); <br>        return sb.toString(); <br>    } <br><br>    @Override <br>    public String getAccessTokenPropertyPath(String clientId) { <br>        return &quot;profile/app-&quot; + clientId; <br>    } <br> <br>    @Override <br>    public User getCurrentUser(SlingHttpServletRequest request) { <br>        Authorizable authorizable = (Authorizable) request.adaptTo(Authorizable.class); <br>        if (authorizable != null &amp;&amp; !authorizable.isGroup()) <br>            return (User) authorizable; <br>        return null; <br>    } <br><br>    @Override <br>    public void onUserUpdate(User user) { <br>        onUserCreate(user); <br>    } <br> <br>    @Override <br>    public OAuthRequest getProtectedDataRequest(String url) { <br>        return new OAuthRequest(Verb.GET, url); <br>    } <br> <br>    @Override <br>    public Map&lt;String, String&gt; parseProfileDataResponse(Response response) throws IOException { <br>        try { <br>            Gson gson = new Gson(); <br>            log.error(&quot;Profile response - &quot; + response.getBody()); <br>            return gson.fromJson(response.getBody(), Map.class); <br>        } catch (JsonSyntaxException je) { <br>            throw new IOException(je); <br>        } <br>    } <br> <br>    @Override <br>    public Map&lt;String, Object&gt; mapProperties(String srcUrl, String clientId, Map&lt;String, Object&gt; existing, <br>                                             Map&lt;String, String&gt; newProperties) { <br>        Map&lt;String, Object&gt; mapped = new HashMap&lt;&gt;(); <br>        Gson gson = new Gson(); <br>        String jsonRep = gson.toJson(newProperties); <br>        Map&lt;String, Object&gt; mappedObject =  gson.fromJson(jsonRep, Map.class); <br>        Object roles = mappedObject.get(&quot;role&quot;); <br>        mapped.putAll(existing); <br>        for (Map.Entry&lt;String, String&gt; prop : newProperties.entrySet()) { <br>            mapped.put(mapProperty(prop.getKey()), prop.getValue()); <br>        } <br>        if (roles != null &amp;&amp; checkIfAuthorized(roles)) { <br>            mapped.put(&quot;profile/roles&quot;, roles); <br>            checkIfAuthorized(roles); <br>        } <br>        return mapped; <br>    } <br><br>    public String getUserIdProperty() { <br>        return &quot;name&quot;; <br>    } <br> <br>    public String getOAuthIdPropertyPath(String clientId) { <br>        return &quot;oauth/oauthid-&quot; + clientId; <br>    } <br><br>    public String getValidateTokenUrl(String clientId, String token) { <br>        this.log.info(&quot;This provider doesn&#39;t support the validation of a token&quot;); <br>        return null; <br>    } <br> <br>    public boolean checkIfAuthorized(Object roles) { <br>        return true; <br>    } <br> <br>    public boolean isValidToken(String responseBody, String clientId, String tokenType) { <br>        this.log.info(&quot;This provider doesn&#39;t support the validation of a token&quot;); <br>        return false; <br>    } <br> <br>    public String getUserIdFromValidateTokenResponseBody(String responseBody) { <br>        this.log.info(&quot;This provider doesn&#39;t support the validation of a token&quot;); <br>        return null; <br>    } <br> <br>    public String getErrorDescriptionFromValidateTokenResponseBody(String responseBody) { <br>        this.log.info(&quot;This provider doesn&#39;t support the validation of a token&quot;); <br>        return null; <br>    } <br><br>} </pre><p>Create CurityOAuth2ProviderImpl.java to support the authentication.</p><pre>package com.mycompany.aem.platform.core.auth.impl; <br><br>import com.adobe.granite.auth.oauth.Provider; <br>import com.adobe.granite.security.user.UserPropertiesService; <br>import com.mycompany.aem.platform.core.auth.CurityOAuth2Api; <br>import com.mycompany.aem.platform.core.auth.AscCurityProviderConfiguration; <br>import com.google.gson.Gson; <br>import com.google.gson.JsonSyntaxException; <br>import org.apache.sling.api.resource.ResourceResolverFactory; <br>import org.osgi.service.component.ComponentContext; <br>import org.osgi.service.component.annotations.*; <br>import org.osgi.service.metatype.annotations.Designate; <br>import org.scribe.model.Response; <br>import org.slf4j.Logger; <br>import org.slf4j.LoggerFactory; <br>import java.io.IOException; <br>import java.util.Map; <br><br>/** <br>* CurityOAuth2ProviderImpl is an implementation of the OAuth2 `Provider` interface that integrates with the Curity <br>* identity server for OAuth 2.0 authentication. This class handles the OAuth2 flow specific to Curity, including <br>* mapping user properties, retrieving user information, and managing user profiles within the AEM environment. <br>* It leverages the CurityOAuth2Api class to facilitate communication with Curity&#39;s OAuth2 endpoints. <br>* <br>* Key responsibilities: <br>* - Maps OAuth2 properties (such as given name, family name, and email) to AEM user profile fields. <br>* - Retrieves user profile data from Curity using OAuth2 access tokens and parses the response. <br>* - Manages user folders and profile paths for storing user-related data within AEM&#39;s repository. <br>* - Configures OAuth2 provider settings during activation using values from the CurityProviderConfiguration. <br>* - Defines a mechanism for user ID mapping based on OAuth2 claims (e.g., `sub` for subject ID). <br>*/ <br><br>@Component(service = Provider.class, <br>property = {&quot;oauth.provider.id=asccurity&quot;} ) <br>@Designate(ocd = CurityProviderConfiguration.class) <br>public class CurityOAuth2ProviderImpl extends OAuth2BaseProvider implements Provider { <br><br>    private final Logger log = LoggerFactory.getLogger(getClass()); <br>    private final String GIVEN_NAME = &quot;profile/givenName&quot;; <br>    private final String FAMILY_NAME = &quot;profile/familyName&quot;; <br>    private final String EMAIL = &quot;profile/email&quot;; <br>    private final String PROFILE_PATH = &quot;profile/&quot;; <br>    private final String SUB = &quot;sub&quot;; <br>    private final String OAUTH_USERINFO = &quot;/oauth-userinfo&quot;; <br><br>    @Reference <br>    private UserPropertiesService userPropertiesService; <br> <br>    @Reference(cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC) <br>    private ResourceResolverFactory resourceResolverFactory; <br><br>    public String mapProperty(String property) { <br>        if (&quot;given_name&quot;.equals(property)) <br>            return GIVEN_NAME; <br>        if (&quot;family_name&quot;.equals(property)) <br>            return FAMILY_NAME; <br>        if (&quot;email&quot;.equals(property)) <br>            return EMAIL; <br>        return getPropertyPath(property); <br>    } <br><br>    @Override <br>    public String mapUserId(final String userId, final Map&lt;String, Object&gt; props) { <br>        return (String) props.get(getPropertyPath(getUserIdProperty())); <br>    } <br><br>    protected String getPropertyPath(final String property) { <br>        return PROFILE_PATH + property; <br>    }<br> <br>    @Override <br>    public String getUserFolderPath(String userId, String clientId, Map&lt;String, Object&gt; props) { <br>        StringBuilder sb = new StringBuilder(getId()); <br>        if (userId != null) <br>            sb.append(&quot;/&quot;).append(userId.substring(0, 4)); <br>        return sb.toString(); <br>    }<br><br>    @Override <br>    public Map&lt;String, String&gt; parseProfileDataResponse(Response response) throws IOException { <br>        try { <br>            Gson gson = new Gson(); <br>            return gson.fromJson(response.getBody(), Map.class); <br>        } catch (JsonSyntaxException je) { <br>            throw new IOException(je); <br>        } <br>    } <br><br>    @Override <br>    public String getUserIdProperty() { <br>        return SUB; <br>    } <br> <br>    @Activate <br>    protected void activate(final CurityProviderConfiguration config) { <br>        super.name = getClass().getSimpleName(); <br>        super.id = config.providerId(); <br>        super.api = new CurityOAuth2Api(config.oAuthBaseURL()); <br>        super.profileUrl = config.oAuthBaseURL() + OAUTH_USERINFO; <br>        super.userPropertiesService = userPropertiesService; <br>        super.resourceResolverFactory = resourceResolverFactory; <br>    }<br><br>    @Deactivate <br>    protected void deactivate(final ComponentContext componentContext) { <br>        log.debug(&quot;deactivating provider id {}&quot;, id); <br>    } <br><br>} </pre><p>Create a Provider Configuration class — CurityProviderConfiguration.java</p><pre>package com.mycompany.aem.platform.core.auth; <br><br>import org.osgi.service.metatype.annotations.AttributeDefinition; <br>import org.osgi.service.metatype.annotations.ObjectClassDefinition; <br><br>/** <br>* CurityProviderConfiguration is an OSGi configuration interface used to define the settings for the Curity OAuth <br>* provider. It provides the configuration options required to integrate Curity&#39;s OAuth 2.0 service for authentication <br>* in an AEM environment. <br>* <br>* This configuration interface provides the below options: <br>* - `oauth.provider.id`: A unique identifier for the OAuth provider (default: &quot;asccurity&quot;). <br>* - `oAuthBaseURL`: The base URL for the Curity OAuth2 service, which is used to construct API endpoints for <br>*   authentication, authorization, and token exchange operations. <br>*/ <br><br>@ObjectClassDefinition(name = &quot;Curity Server Provider Configuration&quot;, <br>        description = &quot;Curity Server Provider Configuration&quot;) <br>public @interface CurityProviderConfiguration { <br><br>    @AttributeDefinition(name = &quot;oauth.provider.id&quot;, description = &quot;OAuth Provider ID&quot;) <br>    String providerId() default &quot;asccurity&quot;; <br><br>    @AttributeDefinition(name = &quot;oAuthBaseURL&quot;, description = &quot;base URL for the provider&quot;) <br>    String oAuthBaseURL(); <br><br>} </pre><p><strong>OSGi Configurations:</strong></p><p>Create a repository initialization script to set up the “asc-users” user group, which will be used for creating users upon successful authentication and configured in the Granite OAuth provider in the next step. Assume there are two folders: “marketing” and “designer”. The path for the marketing folder is “/content/dam/mycompany/marketing”, and the path for the designer folder is “/content/dam/mycompany/designer”. Consider a scenario where the logged-in user should only have access to the assets within the marketing folder and should not be able to access the assets in the designer folder. To achieve this, configure the permissions to grant access to the assets in the “marketing” folder while denying access to the assets in the “designer” folder for the “asc-users” group.</p><p>org.apache.sling.jcr.repoinit.RepositoryInitializer~asc-user-group.cfg.json</p><pre>{ <br>  &quot;scripts&quot;: [ <br>&quot;create path /content/dam/mycompany/marketing (sling:Folder)/jcr:content(nt:unstructured)&quot;, <br>&quot;create path /content/dam /mycompany/designer(sling:Folder)/jcr:content(nt:unstructured)&quot; <br>&quot;create group \&quot;asc-users\&quot;&quot;, <br>&quot;set ACL for \&quot;asc-users\&quot;\n allow jcr:all on /content/dam/mycompany/marketing\nend&quot;, <br>&quot;set ACL for \&quot;asc-users\&quot;\n deny jcr:all on /content/dam /mycompany/designer\nend&quot; <br>] <br>} </pre><p>Create a Granite OAuth Application and Provider configuration — com.adobe.granite.auth.oauth.provider~curity.cfg.json</p><pre>{ <br>  &quot;oauth.client.id&quot;:&quot;$[env:curityClientId]&quot;, <br>  &quot;oauth.redirect.request.params&quot;:true, <br>  &quot;oauth.access.token.persist.cookie&quot;:true, <br>  &quot;oauth.hash.userids&quot;:true, <br>  &quot;oauth.callBackUrl&quot;:&quot;$[env:curityCallbackUrl]&quot;, <br>  &quot;oauth.config.id&quot;:&quot;&lt;config-id&gt;&quot;, <br>  &quot;oauth.client.secret&quot;:&quot;$[secret:curityClientSecret]&quot;, <br>  &quot;oauth.create.users&quot;:true, <br>  &quot;oauth.create.users.groups&quot;:[ <br>    &quot;asc-users&quot; <br>  ], <br>  &quot;oauth.access.token.persist&quot;:true, <br>  &quot;oauth.scope&quot;:[ <br>    &quot;openid&quot; <br>  ], <br>  &quot;oauth.config.provider.id&quot;:&quot;asccurity&quot; <br>}</pre><p>&lt;config-id&gt; — Provide a unique to identify the above provider configuration. It will also be used in the login URL.</p><p>Create a Custom provider configuration — com.mycompany.aem.platform.core.auth.impl.CurityOAuth2ProviderImpl.cfg.json</p><pre>{<br>  &quot;oAuthProviderId&quot;:&quot;&lt;config-id&gt;&quot;, <br>  &quot;oAuthBaseURL&quot;:&quot;&lt;curity-base-url&gt;&quot; <br>} </pre><p>&lt;config-id&gt; — Provide the same config-id given in the Granite OAuth Provider configuration in the previous step.</p><p>&lt;curity-base-url&gt; — You can find this from info available in the client you created for ASC in Curity Sandbox. For example, it will be like <a href="https://login.mycompany.com/oauth/v2.">https://login.mycompany.com/oauth/v2.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*2lIWu_SnasBiU3nW5C3ZVw.png" /></figure><p><strong>Cloud Environment Variables:</strong></p><p>Create the following variables in the AEM Cloud Environment, which will be used in the OSGi configurations:</p><ol><li>curityClientId(Variable) - Add the Client name defined in the Curity setup</li><li>curityCallbackUrl(Variable) - Add the redirect URL whitelisted in the Curity setup</li><li>curityClientSecret(Secret) - Add the Client secret generated during the Curity setup</li></ol><p><strong>Login Integration Testing:</strong></p><p>Create a new login page that includes a login button. Configure the login URL as /j_security_check?configid=&lt;config-id&gt;. When the login button is clicked, users will be redirected to the Curity authentication page. New users can register, while existing users can log in directly.</p><p>Login:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*jaSIK-3w871b3XJ7c9pqBg.jpeg" /></figure><p>Sign Up:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*PNnsJ9AtmFn57LKwlFx__w.png" /></figure><p>Upon successful authentication, the user will be redirected to the URL set in both Curity and AEM.</p><p><strong>Access Permission Testing:</strong></p><p>Additionally, users will only have access to assets within the marketing folder as specified in the permissions and will be restricted from accessing any assets in the designer folder.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8202df6fbf52" width="1" height="1" alt=""><hr><p><a href="https://medium.com/activate-aem/asset-share-commons-login-integration-8202df6fbf52">Asset Share Commons Login Integration</a> was originally published in <a href="https://medium.com/activate-aem">Activate AEM</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MSM: Creation of Custom Rollout Configuration for Site Path Reference Update in Experience…]]></title>
            <link>https://medium.com/activate-aem/msm-creation-of-custom-rollout-configuration-for-site-path-reference-update-in-experience-c25969404602?source=rss----f73c4ff1649e---4</link>
            <guid isPermaLink="false">https://medium.com/p/c25969404602</guid>
            <category><![CDATA[live-copy]]></category>
            <category><![CDATA[experiencefragments]]></category>
            <category><![CDATA[aem]]></category>
            <category><![CDATA[mms]]></category>
            <category><![CDATA[custom-rollout]]></category>
            <dc:creator><![CDATA[Arya Sankari V S]]></dc:creator>
            <pubDate>Fri, 22 Nov 2024 16:36:01 GMT</pubDate>
            <atom:updated>2024-11-22T16:36:01.794Z</atom:updated>
            <content:encoded><![CDATA[<h3>MSM: Creation of Custom Rollout Configuration for Site Path Reference Update in Experience Fragments</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2zuIPIjYLHAx5GdCacv7FA.png" /></figure><p>Multi-Site Manager in AEM helps to use the same site content in multiple locations of the site by leveraging its Live Copy functionality. Live copies maintain a live relationship with the source content, hence achieving content reuse and content synchronization on any updated content. Content synchronization is determined using Rollout configurations, that define which properties are to be synchronized and when the synchronization should occur.</p><p>Usage of out-of-the-box rollout configurations may not satisfy most of our custom requirements. One such example is the site path reference updates, which happen on site pages and not on experience fragments. Experience fragments do not support similar live copy creation as is done for sites. This is because AEM doesn’t use MSM relationships for experience fragment variations. Using a custom rollout configuration, we can achieve site path reference updates on experience fragments.</p><p>Let us try custom rollout configuration creation on this use case for a sample content hierarchy like below:</p><figure><img alt="Sample content hierarchy" src="https://cdn-images-1.medium.com/max/368/1*qWgeWgjJXC9S6mcF3p9RCg.png" /><figcaption>Fig 1: Sample content hierarchy</figcaption></figure><h3>How To Implement This?</h3><h4>1. Create a custom rollout config</h4><p>Under the path /<em>apps/msm/wcm/rolloutconfigs/myproject, </em>create the custom LiveSyncAction. For this, update /<em>apps/msm/wcm/rolloutconfigs/myproject/updateSiteReferences/.content.xml</em>, using the below code:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; <br>&lt;jcr:root xmlns:jcr=&quot;http://www.jcp.org/jcr/1.0&quot;  <br>    xmlns:nt=&quot;http://www.jcp.org/jcr/nt/1.0&quot;  <br>    xmlns:cq=&quot;http://www.day.com/jcr/cq/1.0&quot;  <br>    xmlns:sling=&quot;http://sling.apache.org/jcr/sling/1.0&quot; <br>    jcr:primaryType=&quot;cq:Page&quot;&gt; <br>    &lt;jcr:content <br>        cq:defaultview=&quot;html&quot; <br>        cq:rolloutconfigid53=&quot;cq:trigger=rollout#updateContent/status=true####&quot; <br>        cq:template=&quot;/libs/wcm/msm/templates/rolloutconfig&quot; <br>        cq:trigger=&quot;rollout&quot; <br>        jcr:description=&quot;Custom rollout configuration which updates site page references in experience fragments on rollout trigger&quot; <br>        jcr:primaryType=&quot;nt:unstructured&quot; <br>        jcr:title=&quot;XF: Site References Update Config&quot; <br>        sling:resourceType=&quot;wcm/msm/components/rolloutconfig&quot;&gt; <br>        &lt;referencesUpdateSite jcr:primaryType=&quot;cq:LiveSyncAction&quot;/&gt; <br>    &lt;/jcr:content&gt; <br>&lt;/jcr:root&gt;</pre><p>where,</p><ul><li><strong>cq:trigger</strong> property defines the event to be triggered to make the update. The cq:trigger values can be set to rollout, modification, publish or deactivate, based on the requirement</li><li><strong>referencesUpdateSite</strong> node name defines LiveSyncAction and this name will be set as the <em>liveActionName</em> in the corresponding OSGi service class, which will perform the action.</li></ul><h4><strong>2. </strong>Create custom LiveActionFactory OSGi service</h4><p>While creating the service,</p><ul><li>Set the custom <em>LiveSyncAction</em> as <em>LiveActionFactory.LIVE_ACTION_NAME</em></li><li>Create a custom <em>FilteredAction</em> class and set it as <em>LiveActionFactory.LIVE_ACTION_NAME</em></li></ul><p>Use the below code to create the OSGi service:</p><pre>@Component(immediate = true, <br>    service = LiveActionFactory.class, <br>    property = { <br>        LiveActionFactory.LIVE_ACTION_NAME + &quot;=&quot; + XfSiteReferencesUpdateActionFactory.LIVE_ACTION_CLASS_NAME, <br>        LiveActionFactory.LIVE_ACTION_NAME + &quot;=&quot; + XfSiteReferencesUpdateActionFactory.LIVE_ACTION_NAME <br><br>    }) <br><br>public class XfSiteReferencesUpdateActionFactory extends FilteredActionFactoryBase&lt;XfSiteReferencesUpdateActionFactory.XfSiteReferencesUpdateAction&gt; { <br><br>    public static final String LIVE_ACTION_NAME = &quot;referencesUpdateSite&quot;; <br>    public static final String LIVE_ACTION_CLASS_NAME = &quot;XfSiteReferencesUpdateAction&quot;; <br>    private static final Logger LOG = LoggerFactory.getLogger(XfSiteReferencesUpdateActionFactory.class); <br>    private static final Pattern CONTENT_PATH_PATTERN = Pattern.compile(CONTENT_PATH_REGEXP); <br>    private static final String CONTENT_PATH_REGEXP = &quot;/content/(myproject)[w-/]*&quot;; <br>    private static final Pattern CONTENT_PATH_PATTERN = Pattern.compile(CONTENT_PATH_REGEXP); <br>    <br>    @Reference <br>    private RolloutManager rolloutManager; <br><br>    @Reference <br>    private LiveRelationshipManager relationshipManager; <br><br>    @Activate <br>    @Modified <br>    protected void configure(ComponentContext context) { <br>        setupFilter(context, this.rolloutManager); <br>    } <br><br>    @Override <br>    protected XfSiteReferencesUpdateAction newActionInstance(ValueMap valueMap) throws WCMException { <br>        return new XfSiteReferencesUpdateAction(valueMap, this.getPagePropertyFilter(), this.getComponentFilter(), this); <br>    } <br><br>    @Override <br>    public String createsAction() {<br>        return LIVE_ACTION_NAME;<br>    }<br><br>    class XfSiteReferencesUpdateAction extends FilteredAction {<br>       protected XfSiteReferencesUpdateAction(ValueMap configuration, ItemFilterImpl pageItemFilter, ItemFilterImpl componentItemFilter, BaseActionFactory factory) { <br>           super(configuration, pageItemFilter, componentItemFilter, factory); <br>       } <br><br>       @Override<br>       protected boolean doHandle(Resource source, Resource target, LiveRelationship relation, boolean resetRollout) <br>               throws RepositoryException, WCMException {<br>           return resourceHasNode(source) &amp;&amp; resourceHasNode(target);<br>       } <br><br>       @Override <br>       protected void doExecute(Resource source, Resource target, LiveRelationship relation, boolean resetRollout) <br>               throws RepositoryException, WCMException { <br>           ResourceResolver resolver = target.getResourceResolver();<br>           PageManager pageManager = resolver.adaptTo(PageManager.class);<br><br>           Page targetPage = pageManager.getPage(relation.getLiveCopy().getPath()); <br>           String targetLanguage = targetPage.getName(); <br><br>           Node sourceNode = source.adaptTo(Node.class); <br>           PropertyIterator propIterator = sourceNode.getProperties(); <br><br>           while (propIterator.hasNext()) { <br>               Property property = propIterator.nextProperty(); <br>               if(property.isMultiple()) { <br>                   for(Value value : property.getValues()) { <br>                       processSingleValue(value, resolver, target, pageManager, targetLanguage); <br>                   } <br>               } else { <br>                   processSingleValue(property.getValue(), resolver, target, pageManager, targetLanguage); <br>               } <br>           } <br>       } <br><br>       private void processSingleValue(Value value, ResourceResolver resolver, Resource target, PageManager pageManager, String targetLanguage) throws RepositoryException, WCMException { <br>           if(value.getType() != PropertyType.STRING) { <br>               return;<br>           } <br>           String pathRef = value.getString(); <br>           if(pathRef == null ||!pathRef.contains(&quot;/content/myproject&quot;)) { <br>               return;<br>           } <br><br>           Matcher pathMatcher = CONTENT_PATH_PATTERN.matcher(pathRef); <br>           while (pathMatcher.find()) { <br>               Resource resource = resolver.getResource(pathMatcher.group()); <br>               adjustReferences(pageManager, resource, target, targetLanguage); <br>           } <br>       } <br><br>       private void adjustReferences(PageManager pageManager, Resource resource, Resource target, String targetLanguage) throws RepositoryException, WCMException { <br>           RangeIterator relationshipsIterator = relationshipManager.getLiveRelationships(resource, null, null); <br>           while (relationshipsIterator.hasNext()) { <br>               LiveRelationship relationship = (LiveRelationship) relationshipsIterator.next(); <br>               Page liveCopyPage = pageManager.getPage(relationship.getLiveCopy().getPath()); <br>               if (isSubjectForReferencesAdjustment(liveCopyPage, targetLanguage)) { <br>                   new ReferenceSearch().adjustReferences(target.adaptTo(Node.class), <br>                           relationship.getSourcePath(), relationship.getTargetPath(), true, Collections.emptySet()); <br>               } <br>           } <br>       } <br><br>       private boolean isSubjectForReferencesAdjustment(Page liveCopyPage, String targetLanguage) { <br>           return liveCopyPage != null &amp;&amp; liveCopyPage.getPath().endsWith(targetLanguage); <br>       } <br><br>   } <br><br>}</pre><h3><strong>How to configure?</strong></h3><h4><strong>1. On new live copy creation</strong></h4><p>When creating a new XF live copy, select the newly created rollout config and the Standard rollout config.</p><figure><img alt="Rollout Configs selection on live copy creation" src="https://cdn-images-1.medium.com/max/1024/1*P-WgBAtnp1jJP8qeqbtkBQ.png" /><figcaption>Fig 2: Rollout Configs selection on live copy creation</figcaption></figure><p>Once the live copy is created, you should be able to see the selected configs in the Live Copy tab in Properties as shown below:</p><figure><img alt="Rollout configs selected" src="https://cdn-images-1.medium.com/max/1024/1*xFXNPvjsNwfHWcgh3r0lJQ.png" /><figcaption>Fig 3: Rollout configs selected</figcaption></figure><h4><strong>2. On existing live copies</strong></h4><p>For the existing live copies, even though the option for selecting rollout configuration is present in Properties, it will be saved as a blueprint configuration. As shown below, the JCR property needs to be updated to use the new custom rollout config.</p><figure><img alt="cq:LiveSyncConfig JCR node of a live copy" src="https://cdn-images-1.medium.com/max/1024/1*vHl4Si_Zo4j7IeskKyeqZg.png" /><figcaption>Fig 4: cq:LiveSyncConfig JCR node of a live copy</figcaption></figure><h3><strong>How can we verify?</strong></h3><p>As the path reference update on rollout is not fully implemented for experience fragments, currently with the standard rollout, components might behave differently based on the below scenarios:</p><ul><li><strong>Components with a single path field </strong><br>If a corresponding page exists in the target language, the path is converted to the target language path.</li><li><strong>Components with multiple single-valued path fields </strong><br>If at least one path has a corresponding page in the target language, all single-valued path fields are converted to the respective target language paths.</li><li><strong>Components with multi-field path references </strong><br>Pages with corresponding target language paths are updated, while other paths remain unchanged.</li><li><strong>Components with rich text fields authored with hyperlinks </strong><br>All paths remain unchanged.</li></ul><p>Using the above code implementation, all site path references will be converted to the target page paths like the standard rollout triggered on site pages.</p><h3>Further Enhancements</h3><p>This code implementation works if the languages are at the same level, like the sample content hierarchy shown above. If the live copies are to be kept at a different hierarchy level, this can be achieved by bringing further customizations.</p><p>Methods of the class <em>com.day.cq.wcm.commons.ReferenceSearch</em>, which helps to rewrite the paths can be customized, to achieve this.</p><h4>Summary:</h4><p>MSM is the magic which can help to bring consistency to the entire website with efficient content reuse and synchronization abilities by building live relationships. Customizing rollout configs allows us to leverage the power of MSM into even more use cases for the benefit of content authors!</p><p>In conclusion, implementing a custom rollout configuration for experience fragments significantly enhances the flexibility and efficiency of content management within AEM’s Multi-Site Manager. By addressing the limitations of out-of-the-box configurations, this approach allows for precise synchronization of site path references, ensuring that all elements of a content hierarchy remain coherent and up to date. As organizations strive for greater content reuse and consistency across multiple sites, mastering custom rollout configurations becomes an essential skill for optimizing the performance of AEM. By embracing these techniques, teams can better meet their unique requirements, improving user experience and operational effectiveness in their digital ecosystems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c25969404602" width="1" height="1" alt=""><hr><p><a href="https://medium.com/activate-aem/msm-creation-of-custom-rollout-configuration-for-site-path-reference-update-in-experience-c25969404602">MSM: Creation of Custom Rollout Configuration for Site Path Reference Update in Experience…</a> was originally published in <a href="https://medium.com/activate-aem">Activate AEM</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Email Integration with OAuth SMTP]]></title>
            <link>https://medium.com/activate-aem/email-integration-with-oauth-smtp-e4ccc6ff250d?source=rss----f73c4ff1649e---4</link>
            <guid isPermaLink="false">https://medium.com/p/e4ccc6ff250d</guid>
            <category><![CDATA[aem]]></category>
            <category><![CDATA[email-with-aem]]></category>
            <category><![CDATA[aem-oauth]]></category>
            <category><![CDATA[aem-with-smtp]]></category>
            <category><![CDATA[adobe-experience-manager]]></category>
            <dc:creator><![CDATA[Ashwini Sathe]]></dc:creator>
            <pubDate>Wed, 30 Oct 2024 06:39:46 GMT</pubDate>
            <atom:updated>2024-10-30T06:39:46.481Z</atom:updated>
            <content:encoded><![CDATA[<p>AEM as a Cloud Service offers OAuth 2 support for its integrated Mail Service to allow organisations to adhere to secure email requirements. AEM’s DefaultMailService supports both Basic and OAuth 2 authentication. Basic authentication is easy to achieve but might not support modern security requirements. OAuth 2 is more secure than basic authentication.</p><p><em>OAuth 2 support is available in AEM for multiple email providers like gmail, outlook etc. Here we will be mainly focusing on Microsoft Office 365 Outlook.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l5LjcSbKGRxVe7hu-1miGw.png" /></figure><p>Before we start with the setup, we need to consider below requirements</p><ul><li>Is client SMTP public/internet or private/intranet? — If it is public, then we have to enable <strong>flexible egress</strong> in advanced networking on AEM as a Cloud Service. If it is private, then <strong>dedicated egress</strong> needs to be enabled and the dedicated IP needs to be whitelisted.</li><li>Which SMTP port? — SMTP on ports 25/587/468 needs to be enabled by <strong>port forward proxy, </strong>as by default https is enabled on port 80/443 in AEM.</li></ul><p>Setup involves following steps:</p><ol><li>Setup SMTP on Azure to use Oauth for Outlook.</li><li>Setup on AEM using Oauth Provider and Day CQ mail service configurations.</li><li>Setup Advanced networking on AEM cloud manager for port forwarding</li></ol><h3>Setup Azure account to use SMTP on Oauth2</h3><ol><li>Go to <a href="https://portal.azure.com/">https://portal.azure.com/</a> and log in.</li><li>Search for <strong>Azure Active Directory</strong> in the search bar and click the result.</li><li>Click on <strong>App registrations</strong> -&gt; <strong>New registration</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bqPPtivapeB2DnnGdBhewQ.png" /></figure><p>4. Fill in the information according to your requirements, then click <strong>Register</strong>.</p><p>5. Now go to the created app and click on the <strong>App permissions</strong></p><p><strong>a. Add permission → Select Microsoft graph API → delegated permissions </strong>add <strong>openid</strong> and <strong>offline_access</strong> permissions<strong>.</strong></p><p><strong>b. Add permission → Select Microsoft Office 365 → delegate permissions </strong>and<strong> </strong>add <a href="https://outlook.office.com/SMTP.Send"><strong>https://outlook.office.com/SMTP.Send</strong></a><strong> </strong>permission</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IxztcIznhbKob9F1Dgw_wQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xiTVSNu5mr-ioGjTv9Ot5Q.png" /></figure><p>6. Go to <strong>Authentication → Add platform → Web</strong> and in the Redirect Urls section, add the below URLs — one with and one without a forward slash. And click on save button.</p><p>a. <a href="http://localhost/">http://localhost/</a></p><p>b. <a href="http://localhost/">http://localhost</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FtPxO9JQTq-2-Z3P7WZVWw.png" /></figure><p>7. Go to <strong>Certificates &amp; secrets → New client secret </strong>and add new client secret and make a note of secret key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xr9Z3kfdIzqTGXnjspZCxQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uMSjRU6Yefqg_HpDeok0Vw.png" /></figure><p>8. Go to Overview and make a note of Client ID, Tenant ID</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZBPnbRhUArlVJYKzvCRc5A.png" /></figure><p>9. Now we should have the following information with us which we required for OSGI configuration in AEM.</p><p>a. The Auth URL, constructed with the tenant ID: https://login.microsoftonline.com/&lt;tenantID&gt;/oauth2/v2.0/authorize</p><p>b. The Token URL, constructed with the tenant ID. https://login.microsoftonline.com/&lt;tenantID&gt;/oauth2/v2.0/token</p><p>c. The Refresh URL, constructed with the tenant ID https://login.microsoftonline.com/&lt;tenantID&gt;/oauth2/v2.0/token</p><p>d. The Client ID</p><p>e. The Client Secret (copied from step 7)</p><p>10. Along with the details in step 9 we need a refresh token as well. Let’s see how to generate the refresh token in the next section.</p><h3>Generating Refresh Token</h3><ol><li>Generate auth code — open the below URL in browser by replacing the tenant ID and client ID.</li></ol><blockquote>https://login.microsoftonline.com/&lt;tenantID&gt;/oauth2/v2.0/authorize?client_id=&lt;clientId&gt;&amp;response_type=code&amp;redirect_uri=http://localhost&amp;response_mode=query&amp;scope=https://outlook.office.com/SMTP.Send openid offline_access&amp;state=12345</blockquote><p>2. When asked, login with the user ID using which you would like to send email (from address)</p><p>3. You will be redirected to something like</p><blockquote>http://localhost/?code=&lt;code&gt;&amp;state=12345&amp;session_state=4f984c6b-cc1f-47b9-81b2-66522ea83f81#</blockquote><p>4. Copy the value of &lt;code&gt; from the above URL.</p><p>5. Use the following curl command to get the refresh token. Replace the &lt;tenantId&gt;, &lt;clientID&gt;,&lt;clientSecret&gt; and &lt;code&gt; with details captured.</p><blockquote>curl — location — request POST ‘<a href="https://login.microsoftonline.com/%3ctenantId%3e/oauth2/v2.0/token">https://login.microsoftonline.com/&lt;tenantId&gt;/oauth2/v2.0/token</a>&#39; \</blockquote><blockquote>— header ‘Content-Type: application/x-www-form-urlencoded’ \</blockquote><blockquote>— header ‘Cookie: buid=0.ARgAep0nU49DzUGmoP2wnvyIkcQjsx26HEpOnvHS0akqXQgYAAA.AQABAAEAAAD — DLA3VO7QrddgJg7Wevry9XPJSKbGVlPt5NWYxLtTl3K1W0LwHXelrffApUo_K02kFrkvmGm94rfBT94t25Zq4bCd5IM3yFOjWb3V22yDM7-rl112sLzbBQBRCL3QAAgAA; esctx=AQABAAAAAAD — DLA3VO7QrddgJg7Wevr4a8wBjYcNbBXRievdTOd15caaeAsQdXeBAQA3tjVQaxmrOXFGkKaE7HBzsJrzA-ci4RRpor-opoo5gpGLh3pj_iMZuqegQPEb1V5sUVQV8_DUEbBv5YFV2eczS5EAhLBAwAd1mHx6jYOL8LwZNDFvd2-MhVXwPd6iKPigSuBxMogAA; x-ms-gateway-slice=estsfd; stsservicecookie=estsfd; fpc=Auv6lTuyAP1FuOOCfj9w0U_5vR5dAQAAALDXP9gOAAAAwIpkkQEAAACT2T_YDgAAAA’ \</blockquote><blockquote>— data-urlencode ‘client_id=&lt;clientID&gt;’ \</blockquote><blockquote>— data-urlencode ‘scope=https://outlook.office.com/SMTP.Send<a href="https://graph.microsoft.com/Mail.Read"> </a>openid offline_access’ \</blockquote><blockquote>— data-urlencode ‘redirect_uri=http://localhost&#39; \</blockquote><blockquote>— data-urlencode ‘grant_type=authorization_code’ \</blockquote><blockquote>— data-urlencode ‘client_secret=&lt;clientSecret&gt;’ \</blockquote><blockquote>— data-urlencode ‘code=&lt;code&gt;’</blockquote><p>OR you can get the refresh token via Postman</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H5CDXUPr473ZEMIk8dAGuw.png" /></figure><p>6. Make a note of the refresh token from the response and validate it using the following curl command. In the response you should see the access_token, refresh_token, scope, expiry etc.</p><blockquote>curl — location — request POST ‘<a href="https://login.microsoftonline.com/%3ctenetId%3e/oauth2/v2.0/token">https://login.microsoftonline.com/&lt;tenetId&gt;/oauth2/v2.0/token</a>&#39; \</blockquote><blockquote>— header ‘Content-Type: application/x-www-form-urlencoded’ \</blockquote><blockquote>— header ‘Cookie: buid=0.ARgAep0nU49DzUGmoP2wnvyIkcQjsx26HEpOnvHS0akqXQgYAAA.AQABAAEAAAD — DLA3VO7QrddgJg7Wevry9XPJSKbGVlPt5NWYxLtTl3K1W0LwHXelrffApUo_K02kFrkvmGm94rfBT94t25Zq4bCd5IM3yFOjWb3V22yDM7-rl112sLzbBQBRCL3QAAgAA; esctx=AQABAAAAAAD — DLA3VO7QrddgJg7Wevr4a8wBjYcNbBXRievdTOd15caaeAsQdXeBAQA3tjVQaxmrOXFGkKaE7HBzsJrzA-ci4RRpor-opoo5gpGLh3pj_iMZuqegQPEb1V5sUVQV8_DUEbBv5YFV2eczS5EAhLBAwAd1mHx6jYOL8LwZNDFvd2-MhVXwPd6iKPigSuBxMogAA; x-ms-gateway-slice=estsfd; stsservicecookie=estsfd; fpc=Auv6lTuyAP1FuOOCfj9w0U_IezHLAQAAAPeNSdgOAAAA’ \</blockquote><blockquote>— data-urlencode ‘client_id=&lt;client_id&gt;’ \</blockquote><blockquote>— data-urlencode ‘scope=https://outlook.office.com/SMTP.Send email openid profile offline_access’ \</blockquote><blockquote>— data-urlencode ‘redirect_uri=http://localhost&#39; \</blockquote><blockquote>— data-urlencode ‘grant_type=refresh_token’ \</blockquote><blockquote>— data-urlencode ‘client_secret=&lt;client_secret&gt;’ \</blockquote><blockquote>— data-urlencode ‘refresh_token=&lt;refreshToken&gt;’</blockquote><p>OR via Postman</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M41bQMqt6whD2nm9kAlIYA.png" /></figure><h3>Integration with AEM as cloud service for Oauth2</h3><ol><li>Configure the <em>CQ Mailer SMTP OAuth2 Provider </em>config with all the details gathered in azure application setup.</li></ol><blockquote>com.day.cq.mailer.oauth.impl.OAuthConfigurationProviderImpl</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HhyiTgrpreDMiSxOvfajiw.png" /></figure><p>2. Add the secret variables in Cloud for SMTP_OAUTH_CLIENT_SECRET and SMTP_OAUTH_REFRESH_TOKEN</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b4VbHvBTbnR5IdBunhexRQ.png" /></figure><p>3. Configure the <em>Day CQ mail service</em></p><blockquote>com.day.cq.mailer.DefaultMailService</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TXiX9Bw4b_SpK-diYF1JCQ.png" /></figure><h3>Advanced Networking for AEMaaCS</h3><ol><li>Go to Network Infrastructures within Cloud Manager and enable flexible/dedicated port egress depending on your project requirements. Follow the Adobe document to do this setup <a href="https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/security/configuring-advanced-networking#configuring-flexible-port-egress-provision-ui">https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/security/configuring-advanced-networking#configuring-flexible-port-egress-provision-ui</a></li></ol><p>2. Go to environments and open any environment then go to the <strong>Advanced network configuration</strong> tab and add a configuration as shown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ArrcL7gfHlccalUwIC0ZwA.png" /></figure><h4>Troubleshoot:</h4><ul><li><em>Error:</em></li></ul><p>com.day.cq.mailer.oauth.impl.OAuthCodeServiceImpl error occurred while fetching accessToken using RefreshToken</p><p>org.apache.oltu.oauth2.common.exception.OAuthProblemException: invalid_grant, AADSTS70000: Provided grant is invalid or malformed.</p><p><em>Resolution:</em></p><p>Check the values for client ID, client secret and refresh token if those are matching. If still issues persist, generate a new refresh token and try again.</p><ul><li><em>Error:</em></li></ul><p><em>com.day.cq.mailer.MailingException</em>: <em>javax.mail.MessagingException</em>: 535 5.7.3 Authentication unsuccessful</p><p><em>Resolution:</em></p><p>This error occurs for multiple reasons, one of which is that the account is a distribution list, so it is not allowed to send emails.</p><p>Another might be the account which we used to generate the refresh token is different from the from address/SMTP user configured in DefaultMailService. We must use the same account as STMP user and from address also the account used to generate the token should be same.</p><ul><li><em>Error:</em></li></ul><p>com.day.cq.mailer.oauth.impl.OAuthMailerServiceImpl error occurred while sending mail using oauth</p><p><em>javax.mail.MessagingException</em>: 451 4.7.0 Temporary server error. Please try again later. PRX5</p><p><em>Resolution:</em></p><p>Verify the client SMTP if it is private/intranet then check the advanced network config if it is flexible you have to change it to dedicated on and whitelist the dedicated IP at Azure end.</p><h3>Conclusion:</h3><p>In this post, we’ve explored setting up configurations on Azure for OAuth 2 enablement, generating the refresh token, and utilizing these credentials within AEM configurations alongside advanced cloud networking setup. With these steps, you are now equipped to seamlessly send emails from AEM to Microsoft Outlook using OAuth 2, ensuring enhanced email security.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4ccc6ff250d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/activate-aem/email-integration-with-oauth-smtp-e4ccc6ff250d">Email Integration with OAuth SMTP</a> was originally published in <a href="https://medium.com/activate-aem">Activate AEM</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AEM’s Two-Column Layout for Enhanced Web Development]]></title>
            <link>https://medium.com/activate-aem/aems-two-column-layout-for-enhanced-web-development-01699a110cfe?source=rss----f73c4ff1649e---4</link>
            <guid isPermaLink="false">https://medium.com/p/01699a110cfe</guid>
            <category><![CDATA[aem-tips-for-developers]]></category>
            <category><![CDATA[2-column-with-aem]]></category>
            <category><![CDATA[aem-development]]></category>
            <category><![CDATA[adobe-aem]]></category>
            <category><![CDATA[aem-as-cloud-service]]></category>
            <dc:creator><![CDATA[Jenitha Baskaran]]></dc:creator>
            <pubDate>Fri, 04 Oct 2024 09:17:27 GMT</pubDate>
            <atom:updated>2024-10-04T11:59:55.484Z</atom:updated>
            <content:encoded><![CDATA[<p>The two-column layout is a fundamental feature in web design, offering a balanced and structured approach to presenting content. In AEM, a two-column layout component allows developers and content authors to divide web page content into two distinct columns. This division is not merely aesthetic but also serves practical purposes, such as improved readability, visual hierarchy, and responsive design. This blog explores how AEM leverages the two-column layout component to enhance web development and content presentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9f0fPVj960jeRPUMyyGHQg.png" /><figcaption>Experience Web Development: Design Smarter with AEM’s Two-Column Layout.</figcaption></figure><h4><strong>Dynamic Design for Diverse Needs</strong></h4><p>The two-column layout component in AEM provides developers with a flexible grid system to organize and display content on web pages. It adapts effortlessly to a variety of content types:</p><ul><li><strong>Interactive Landing Pages</strong>: Create impactful first impressions by combining media-rich elements with informative text, guiding users through a compelling narrative.</li><li><strong>Flexible Content Blocks</strong>: Seamlessly integrate diverse content elements such as images, videos, forms, and CTAs within a structured grid system, optimising user engagement and conversion paths.</li></ul><h4><strong>Technical Details:</strong></h4><p><strong>Back-end:</strong></p><ul><li>Add a dialogue field that will allow an author to specify the required data.</li></ul><pre>&lt;jcr:root xmlns:sling=&quot;http://sling.apache.org/jcr/sling/1.0&quot; xmlns:granite=&quot;http://www.adobe.com/jcr/granite/1.0&quot; <br>          xmlns:jcr=&quot;http://www.jcp.org/jcr/1.0&quot; xmlns:nt=&quot;http://www.jcp.org/jcr/nt/1.0&quot; <br>          xmlns:cq=&quot;http://www.day.com/jcr/cq/1.0&quot; <br>          jcr:primaryType=&quot;nt:unstructured&quot; <br>          jcr:title=&quot;Two Column Layout&quot; <br>          sling:resourceType=&quot;cq/gui/components/authoring/dialog&quot;&gt; <br>    &lt;content<br>        jcr:primaryType=&quot;nt:unstructured&quot; <br>        sling:resourceType=&quot;granite/ui/components/foundation/container&quot;&gt; <br>        &lt;layout <br>            jcr:primaryType=&quot;nt:unstructured&quot; <br>            sling:resourceType=&quot;granite/ui/components/foundation/layouts/fixedcolumns&quot;/&gt; <br>        &lt;items jcr:primaryType=&quot;nt:unstructured&quot;&gt; <br>            &lt;column <br>                jcr:primaryType=&quot;nt:unstructured&quot; <br>                sling:resourceType=&quot;granite/ui/components/coral/foundation/container&quot;&gt; <br>                &lt;items jcr:primaryType=&quot;nt:unstructured&quot;&gt; <br>                    &lt;cards <br>                        jcr:primaryType=&quot;nt:unstructured&quot; <br>                        sling:resourceType=&quot;granite/ui/components/coral/foundation/form/multifield&quot; <br>                        composite=&quot;{Boolean}true&quot; <br>                        fieldLabel=&quot;Statement Cards&quot; <br>                        required=&quot;true&quot; <br>                        validation=&quot;multifield-length&quot;&gt; <br>                        &lt;granite:data <br>                            jcr:primaryType=&quot;nt:unstructured&quot; <br>                            max-items=&quot;8&quot;/&gt; <br>                        &lt;field <br>                            jcr:primaryType=&quot;nt:unstructured&quot; <br>                            sling:resourceType=&quot;granite/ui/components/coral/foundation/container&quot; <br>                            cq-msm-lockable=&quot;./cards&quot; <br>                            name=&quot;./cards&quot;&gt; <br>                            &lt;items jcr:primaryType=&quot;nt:unstructured&quot;&gt; <br>                                &lt;cardHeadline <br>                                    jcr:primaryType=&quot;nt:unstructured&quot; <br>                                    sling:resourceType=&quot;granite/ui/components/coral/foundation/form/textfield&quot; <br>                                    cq-msm-lockable=&quot;./cardHeadline&quot; <br>                                    emptyText=&quot;Card Headline&quot; <br>                                    name=&quot;./cardHeadline&quot; <br>                                    required=&quot;true&quot;/&gt; <br>                                &lt;cardDescription <br>                                    jcr:primaryType=&quot;nt:unstructured&quot; <br>                                    sling:resourceType=&quot;granite/ui/components/coral/foundation/form/textarea&quot; <br>                                    cq-msm-lockable=&quot;./statDescription&quot; <br>                                    emptyText=&quot;Card Description&quot; <br>                                    required=&quot;true&quot; <br>                                    name=&quot;./cardDescription&quot;/&gt; <br>                            &lt;/items&gt; <br>                        &lt;/field&gt; <br>                    &lt;/cards&gt; <br>                &lt;/items&gt; <br>            &lt;/column&gt; <br>        &lt;/items&gt; <br>    &lt;/content&gt; <br>&lt;/jcr:root&gt;</pre><ul><li>Create a sling model to read in the authored data from our component.</li></ul><pre>package com.aem.base.core.models; <br>import org.osgi.annotation.versioning.ConsumerType; <br>import com.adobe.cq.export.json.ComponentExporter; <br>import java.util.List; <br><br>@ConsumerType<br>public interface TwoColumnLayout extends Component, ComponentExporter { <br>    List&lt;StatementCard&gt; getStatementCard(); <br>}</pre><pre>package com.aem.base.core.models; <br>import com.adobe.cq.export.json.ComponentExporter; <br>import org.osgi.annotation.versioning.ConsumerType; <br><br>@ConsumerType <br>public interface StatementCard extends Component, ComponentExporter { <br>    String getTitle(); <br>    String getDescription(); <br>}</pre><pre>@Model (<br>    adaptable = {SlingHttpServletRequest.class}, <br>    adapters = {TwoColumnLayout.class, ComponentExporter.class}, <br>    resourceType = TwoColumnLayoutImpl.RESOURCE_TYPE <br>)<br><br>@Exporter (name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION) <br>public class TwoColumnLayoutImpl extends BaseModel implements TwoColumnLayout { <br>   public static final String RESOURCE_TYPE = &quot;aem-base/components/content/two-column-layout&quot;; <br>   @ChildResourceFromRequest (injectionStrategy = InjectionStrategy.OPTIONAL, name = &quot;cards&quot;) <br>   private List&lt;StatementCard&gt; cards; <br><br>   @Override <br>   public List&lt;StatementCard&gt; getStatementCard() { <br>     return cards != null ? Collections.unmodifiableList(cards) : null; <br>  }<br>}</pre><pre>@Model ( <br>   adaptables = {SlingHttpServletRequest.class}, <br>   adapters = {StatementCard.class, ComponentExporter.class} <br>) <br><br>@Exporter (name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION) <br>public class StatementCardImpl extends BaseModel implements StatementCard { <br>   @SlingObject (injectionStrategy = InjectionStrategy.OPTIONAL) <br>   private SlingHttpServletRequest slingRequest; <br><br>   @ValueMapValue (injectionStrategy = InjectionStrategy.OPTIONAL) <br>   private String cardHeadline; <br><br>   @ValueMapValue (injectionStrategy = InjectionStrategy.OPTIONAL) <br>   private String cardDescription; <br><br>   @Override <br>   public String getTitle() { <br>     return cardHeadline; <br>   }<br><br>   @Override <br>   public String getDescription() { <br>     return cardDescription; <br>   }<br>}</pre><ul><li>Transition to HTL/ Sightly</li></ul><pre>&lt;div data-sly-use.twoColumnLayoutModel=&quot;com.aem.base.core.models.TwoColumnLayout&quot; <br>data-sly-test.statementCard=&quot;${twoColumnLayoutModel.statementCard}&quot; class=&quot;cmp-two-column-layout__container&quot; id=&quot;${twoColumnLayoutModel.id}&quot;&gt; <br>   &lt;div class=&quot;cmp-two-column-layout-card-headline&quot; data-sly-test=&quot;${item.title}&quot;&gt;${item.title}&lt;/div&gt; <br>&lt;/div&gt;</pre><p><strong>Front-end:</strong></p><p>Developing a two-column layout in front-end development involves creating a visually appealing and functional layout that effectively organizes content into two distinct columns. This approach is commonly used in web design to present information in a structured and visually balanced manner.</p><pre>&lt;div data-sly-use.twoColumnLayoutModel=&quot;com.aem.base.core.models.TwoColumnLayout&quot;<br>    data-sly-test.statementCard=&quot;${twoColumnLayoutModel.statementCard}&quot; class=&quot;cmp-two-column-layout__container&quot;<br>    id=&quot;${twoColumnLayoutModel.id}&quot;&gt;<br>    &lt;ul class=&quot;cmp-two-column-feature-statement-cards&quot; data-sly-list=&quot;${statementCard}&quot;&gt;<br>        &lt;li&gt;<br>            &lt;div class=&quot;cmp-two-column-feature__content&quot;&gt;<br>                &lt;div class=&quot;cmp-two-column-layout-card-headline&quot; data-sly-test=&quot;${item.title}&quot;&gt; ${item.title} &lt;/div&gt;<br>                &lt;div class=&quot;cmp-two-column-layout-card-description&quot; data-sly-test=&quot;${item.description}&quot;&gt;<br>                    ${item.description @ context=&quot;html&quot;} &lt;/div&gt;<br>            &lt;/div&gt;<br>        &lt;/li&gt;<br>    &lt;/ul&gt;<br>&lt;/div&gt;</pre><p>It sets up a structured two-column layout component in Adobe Experience Manager (AEM). It uses Sightly (data-sly-* directives) for dynamic data binding and conditional rendering based on <strong>TwoColumnLayoutModel</strong>.</p><p>The component includes a list that iterates over statementCard items to generate individual cards (&lt;li&gt;) containing title, description, and a link button.</p><ul><li>The &lt;ul&gt; (cmp-two-column-feature-statement-cards) iterates over statementCard, dynamically generating li items.</li><li>Each &lt;li&gt; contains title and description. This content can be customized based on the requirements.</li></ul><p>This setup ensures flexibility and maintainability while leveraging AEM’s component-based architecture for efficient content management and presentation.</p><p><strong>CSS:</strong></p><p>Creating a two-column layout can be achieved in various ways using CSS, each with its own strengths and weaknesses. Here’s a comparison of the different methods: <strong>CSS Grid, Flexbox and CSS Columns.</strong></p><p><strong>Using Flex Layout:</strong></p><pre>.cmp-two-column-layout__container { <br>  padding: 20px; <br>} <br><br>.cmp-two-column-feature-statement-cards { <br>  display: flex; <br>  flex-wrap: wrap; <br>  gap: 20px; /* Space between items */ <br>  margin: 0; <br>  padding: 0; <br>  list-style-type: none; <br>} <br><br>.cmp-two-column-feature-statement-cards li { <br>  flex: 1 1 calc(50% - 20px); /* Two columns with space between */ <br>  box-sizing: border-box; <br>  margin: 0; <br>} <br><br>.cmp-two-column-feature__content { <br>  background: #FFCBA4; <br>  border: 1px solid #ddd; <br>  border-radius: 8px; <br>  padding: 20px; <br>} <br><br>.cmp-two-column-layout-card-headline { <br>  font-size: 18px; <br>  font-weight: bold; <br>  margin-bottom: 10px; <br>} <br><br>.cmp-two-column-layout-card-description { <br>  font-size: 16px; <br>} <br><br>/* Responsive adjustments */ <br>@media (max-width: 768px) { <br>  .cmp-two-column-feature-statement-cards li { <br>    flex: 1 1 100%; /* Single column on smaller screens */ <br>  }<br>}<br><br>@media (max-width: 600px) { <br>  .cmp-two-column-layout__container { <br>    padding: 10px; /* Adjust padding for smaller screens */ <br>  } <br>} </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cpEteBWCNIkQWhc1bBbO_g.png" /></figure><p>Having trouble with CSS Flexbox? Try playing <a href="http://flexboxfroggy.com/">FlexboxFroggy</a> — it’s a fun game that can help you learn it!</p><p><strong>Using Column Layout:</strong></p><pre>.cmp-two-column-layout__container { <br>  padding: 20px; <br>} <br><br>.cmp-two-column-feature-statement-cards { <br>  column-count: 2; /* Two columns */<br>  column-gap: 20px; /* Space between columns */<br>  margin: 0;<br>  padding: 0;<br>  list-style-type: none;<br>}<br><br>.cmp-two-column-feature-statement-cards li { <br>  background: #FFCBA4; <br>  border: 1px solid #ddd; <br>  border-radius: 8px; <br>  padding: 20px; <br>  box-sizing: border-box; <br>  margin-bottom: 20px; /* Space between items */ <br>}<br><br>.cmp-two-column-layout-card-headline { <br>  font-size: 18px; <br>  font-weight: bold; <br>  margin-bottom: 10px; <br>} <br><br>.cmp-two-column-layout-card-description { <br>  font-size: 16px; <br>} <br><br>/* Responsive adjustments */ <br>@media (max-width: 768px) { <br>  .cmp-two-column-feature-statement-cards { <br>    column-count: 1; /* Single column on smaller screens */ <br>  }<br>}<br><br>@media (max-width: 600px) { <br>  .cmp-two-column-layout__container { <br>    padding: 10px; /* Adjust padding for smaller screens */ <br>  } <br>} </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e2qs8j8lqlthbf60LXISZA.png" /></figure><p><strong>Using Grid Layout:</strong></p><p><strong>Method #1: CSS Grid</strong></p><pre>body { <br>  margin: 0; <br>  font-family: Arial, sans-serif; <br>} <br><br>.cmp-two-column-layout__container { <br>  padding: 20px; <br>} <br><br>.cmp-two-column-feature-statement-cards { <br>  display: grid; <br>  grid-template-columns: repeat(2, 1fr); /* Two columns */ <br>  gap: 20px; /* Space between columns */<br>  list-style-type: none; <br>  margin: 0; <br>  padding: 0; <br>} <br><br>.cmp-two-column-feature-statement-cards li { <br>  background: #FFCBA4; <br>  border: 1px solid #ddd; <br>  border-radius: 8px; <br>  box-sizing: border-box; <br>  display: flex; <br>  flex-direction: column;<br>  padding: 20px;<br>} <br><br>.cmp-two-column-layout-card-headline { <br>  color: #614051; <br>  font-size: 18px; <br>  font-weight: bold; <br>  margin-bottom: 10px; <br>} <br><br>.cmp-two-column-layout-card-description { <br>  font-size: 16px; <br>} <br><br>/* Responsive adjustments */ <br>@media (max-width: 768px) { <br>  .cmp-two-column-feature-statement-cards { <br>    grid-template-columns: 1fr; /* Single column on smaller screens */ <br>  }<br>}<br><br>@media (max-width: 600px) { <br>  .cmp-two-column-layout__container { <br>    padding: 10px; /* Adjust padding for smaller screens */ <br>  }<br>} </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KDFj-dDoq0MSk22-L4zvbg.png" /></figure><p>New to CSS Grid? Explore <a href="https://cssgridgarden.com/">CSSGridGarden</a> — a playful and speedy way to pick it up quickly!</p><p><strong>Method #2: AEM Grid</strong></p><ul><li>In HTML, apply the grid column classes to ensure the list items span the appropriate number of columns:</li></ul><pre>&lt;div data-sly-use.twoColumnLayoutModel=&quot;com.aem.base.core.models.TwoColumnLayout&quot;<br>    data-sly-test.statementCard=&quot;${twoColumnLayoutModel.statementCard}&quot;<br>    class=&quot;cmp-two-column-layout__container aem-Grid&quot;&gt;<br>    &lt;ul class=&quot;cmp-two-column-feature-statement-cards&quot;&gt;<br>        &lt;data-sly-list.items=&quot;${twoColumnLayoutModel.statementCard}&quot;&gt;<br>            &lt;li<br>                class=&quot;cmp-two-column-feature__content aem-Grid-column aem-Grid-column--default--6 aem-Grid-column--phone--12&quot;&gt;<br>                &lt;div class=&quot;cmp-two-column-layout-card-headline&quot; data-sly-test=&quot;${item.title}&quot;&gt; ${item.title} &lt;/div&gt;<br>                &lt;div class=&quot;cmp-two-column-layout-card-description&quot; data-sly-test=&quot;${item.description}&quot;&gt;<br>                    ${item.description @context=&quot;html&quot;} &lt;/div&gt;<br>            &lt;/li&gt;<br>            &lt;/data-sly-list.items&gt;<br>    &lt;/ul&gt;<br>&lt;/div&gt;</pre><p>Define column spans for items in a <a href="https://adobe-marketing-cloud.github.io/aem-responsivegrid/">12-column grid system</a> using CSS setup:</p><ul><li><em>.aem-Grid</em> sets up the grid container using predefined grid mixin.</li><li><em>.aem-Grid-column — default — 6 </em>is used to span 6 out of 12 columns, which creates the two-column layout.</li><li><em>.aem-Grid-column — phone — 12</em> ensures that on smaller screens, the items span the full width (stacked layout).</li></ul><pre>@import (once) &quot;/libs/wcm/foundation/clientlibs/grid/grid_base.less&quot;;<br>@max_col: 12;<br><br>.aem-Grid {<br>    .generate-grid(default, @max_col); /* 12-column grid by default */<br>}<br><br>/* Default column span for grid items */<br>.aem-Grid-column--default--6 {<br>    grid-column: span 6; /* Spans 6 out of 12 columns, creating a two-column layout */<br>}<br><br>@media (max-width: 768px) {<br>    .aem-Grid {<br>        .generate-grid(phone, @max_col);<br>    }<br><br>    .aem-Grid-column--phone--12 {<br>        grid-column: span 12; /* Full width on smaller screens */<br>    }<br>}<br><br>@media (min-width: 769px) and (max-width: 1200px) {<br>    .aem-Grid {<br>        .generate-grid(tablet, @max_col);<br>    }<br><br>    .aem-Grid-column--tablet--6 {<br>        grid-column: span 6;<br>    }<br>}</pre><p>This CSS code snippet defines styles for a two-column layout component in a modular and responsive manner using LESS. It leverages different methods for layout flexibility, incorporates mixins (i.e., @media (max-width: 768px)) for responsive design adjustments and ensures consistent typography and spacing throughout.</p><ul><li><strong>CSS Grid</strong> excels in creating complex, <strong><em>two-dimensional</em></strong> layouts and provides precise control over the placement of items in both rows and columns.</li><li><strong>Flexbox</strong> is ideal for simple, <strong><em>one-dimensional</em></strong> layouts where items need to be aligned or distributed along a row or column.</li><li><strong>CSS Columns</strong> is best for straightforward <strong><em>multi-column</em></strong> text layouts (<strong><em>masonry layout</em></strong>) but lacks the flexibility and control required for more complex layouts.</li></ul><p>Choosing the right method depends on the specific requirements of your layout and the complexity of the design you need to implement.</p><h4><strong>Conclusion</strong></h4><p>AEM’s two-column layout offers a versatile solution for creating compelling web pages. By leveraging its customization options, responsive design capabilities, and seamless integration with AEM’s ecosystem, developers can craft visually appealing and user-friendly experiences that drive business growth in today’s competitive digital landscape.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01699a110cfe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/activate-aem/aems-two-column-layout-for-enhanced-web-development-01699a110cfe">AEM’s Two-Column Layout for Enhanced Web Development</a> was originally published in <a href="https://medium.com/activate-aem">Activate AEM</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Personalization Techniques with Adobe Target]]></title>
            <link>https://medium.com/activate-aem/personalization-techniques-with-adobe-target-84b0ca7be3f6?source=rss----f73c4ff1649e---4</link>
            <guid isPermaLink="false">https://medium.com/p/84b0ca7be3f6</guid>
            <category><![CDATA[personalization]]></category>
            <category><![CDATA[adobe-experience-cloud]]></category>
            <category><![CDATA[targeted-personalization]]></category>
            <category><![CDATA[aem-with-target]]></category>
            <category><![CDATA[adobe-target]]></category>
            <dc:creator><![CDATA[Tara Sasaank Desu]]></dc:creator>
            <pubDate>Tue, 17 Sep 2024 03:31:28 GMT</pubDate>
            <atom:updated>2024-09-17T03:31:27.584Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*idalEBqP5PRPUPFTM6tcFg.png" /></figure><h3><strong>Introduction</strong></h3><p>Giving personalized experiences to users is an important part of digital marketing today. Not only does personalization increase user engagement, but it increases customer satisfaction and conversion rates dramatically. With Adobe Target, marketers and developers can introduce personalization via web, mobile or other channels.</p><p>This document gives a complete overview of how to use Adobe Target to implement different personalization techniques. It covers a variety of techniques that can be applied, from basic A/B testing to complicated automated personalization, to deliver customized experiences to your audience.</p><p>Whether you are new to Adobe Target or want to improve more in personalization, this documentation will provide you with practical insights, examples, and best practices to help you succeed in your personalization journey.</p><h3><strong>Introduction to Adobe Target</strong></h3><p>Adobe Target is the Adobe Experience Cloud solution that provides everything you need to tailor and personalize your customers’ experiences. Target helps you maximize revenue on your web and mobile sites, apps, social media, and other digital channels.</p><p>This is a powerful tool that enables personalized experiences for marketers to deliver to their audiences across websites, mobile applications, and other digital platforms. Using Adobe Target, marketers can dynamically create content, offers, and recommendations that are relevant to users according to their behaviours, preferences, and other facts about them.</p><p><strong>Important features of Adobe Target</strong></p><ul><li><a href="#7312"><strong>A/B Testing</strong></a><strong>:</strong> Comparing two versions of a web page or app to determine which one performs better.</li><li><a href="#ad7c"><strong>Automated Personalization</strong></a><strong>:</strong> Using machine learning algorithms to deliver personalized experiences based on user behaviour.</li><li><a href="#28b3"><strong>Experience Targeting</strong></a><strong>:</strong> Creating different experiences for different audience segments.</li><li><a href="#be7b"><strong>Multivariate Testing</strong></a><strong>:</strong> Testing multiple variations of multiple elements on a webpage simultaneously to find the best combination.</li><li><a href="#aaef"><strong>Recommendations</strong></a><strong>:</strong> Providing personalized product or content recommendations based on user behaviour and preferences.</li><li><a href="#28b2"><strong>Audience Segmentation</strong></a><strong>: </strong>Grouping users based on specific criteria to deliver personalized experiences.</li><li><a href="#c9cf"><strong>Geo-Targeting</strong></a><strong>:</strong> Delivering content or offers to users based on their geographic location.</li></ul><h3><strong>Creating an activity in Adobe Target</strong></h3><p>Before you can start A/B testing or any other type of personalization in Adobe Target, you need to know how to create an activity. An activity is a container for your test or personalization campaign, and it allows you to define the parameters and goals of your experiment.</p><p><strong>Steps to create an activity:</strong></p><ul><li><strong>Sign in to Adobe Target:</strong> Sign in to Adobe Target by providing your credentials.</li><li><strong>Navigate to Activities:</strong> Click the Activities tab from within Adobe Target.</li><li><strong>Create a New Activity:</strong> Click on the “Create Activity” button to start a new activity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-aOVcyF3h0vutMCK" /><figcaption>Click on the “Create Activity” button which is highlighted</figcaption></figure><ul><li><strong>Choose Activity Type:</strong> Once you click on that, you will be provided with a number of options such as: A/B Test, Experience Targeting, Automated Personalization.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*MbDQ_HFOGc4u2BsbU2PEew.png" /><figcaption>Different types of activities that can be created using Adobe Target</figcaption></figure><ul><li><strong>Define Activity Settings:</strong> Fill in the details like the name of the activity, and activity URL.</li><li><strong>Set Up Variations:</strong> Create the number of variations based on the activity type.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*ymxI3Ubu-iwPJazB3hzdMA.png" /><figcaption>Click on the “+ Add Experience” button to create new variations</figcaption></figure><ul><li><strong>Set Up Targeting:</strong> In this step, we allocate the audience to the variations based on priority. For example, in an A/B test requiring a 50–50 split, each variation will be shown to 50% of the audience.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PbEC8l76WRDpkJWF" /></figure><ul><li><strong>Set goals and metrics:</strong> Define the goals of your activity, e.g. CTR or conversion rate, and specify which matrix you will use to measure this success.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rDmlglpEgvTTSSan" /></figure><ul><li><strong>Save and Activate:</strong> Save and activate the set-up activity. Activation will start the process of running your test or personalization campaign.</li></ul><h3><strong>A/B testing with Adobe Target</strong></h3><p>A/B testing, also known as split testing, is a method used to compare two versions of a web page or app to determine which one performs better. Adobe Target offers robust A/B testing capabilities that allow marketers to test different variations of content, design, or functionality to optimize user engagement and conversion rates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*UTGxzlqFqGorNHH3" /><figcaption>To create an A/B test click on “Create Activity” and select A/B Test</figcaption></figure><p><strong>Best practices for A/B testing</strong></p><ul><li>Test one element at a time so that you can isolate the effect of each change.</li><li>Ensure your test has a large enough sample size to yield statistically significant results.</li></ul><p>A/B Testing with Adobe Target allows marketers to make data-informed decisions to elevate their digital experiences for better business outcomes.</p><p><strong>Example: A/B testing a CTA Button</strong></p><p>Suppose you want to test two different colours for a call-to-action (CTA) button on your website. You create two variations of the button: one in red and one in blue. Adobe Target then displays each version to a segment of your audience and tracks how many users click on each button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*Z4PAjpjqP0rfqSI1bmCdAw.png" /><figcaption>Sample code for creating the variation of button colour</figcaption></figure><p>After running the test for a sufficient period, you analyze the results. If the red button has a higher click-through rate than the blue button, you can conclude that the red button is more effective at capturing user attention and driving engagement.</p><h3><strong>Automated Personalization with Adobe Target</strong></h3><p>Automated Personalization is used inside Adobe Target to deliver personalization for users based on their behaviour, preferences, and other data using machine learning algorithms. It allows marketers to continue providing relevant content and relevant offers to each user, thus improving their engagement and conversion rates.</p><p>The idea would be tested through efficiency by applying the best approach in terms of providing this visitor with the best experience. For instance, using the Random Forest Algorithm.</p><p><strong>How Automated Personalization works in Adobe Target</strong></p><ul><li><strong>Data Collection:</strong> Adobe Target gathers data on user behavior, like which pages they have viewed, products they have looked at, and actions taken.</li><li><strong>Segmentation:</strong> Target makes use of this information to segment the users into groups of certain characteristics or behaviors that they share.</li><li><strong>Algorithmic Personalization:</strong> Adobe Target’s machine learning algorithms analyze these segments to identify patterns and trends. Based on these insights, Adobe Target automatically delivers personalized content and offers to each user.</li></ul><p><strong>Benefits of Automated Personalization</strong></p><ul><li><strong>Efficiency:</strong> Automated Personalization reduces the manual effort required to create and manage personalized experiences.</li><li><strong>Accuracy:</strong> Machine learning algorithms can analyze large amounts of data to identify relevant patterns and trends, leading to more accurate personalization.</li><li><strong>Scalability:</strong> Automated Personalization can scale to accommodate large audiences, ensuring that each user receives a personalized experience.</li><li><strong>Real-Time Optimization:</strong> Automated Personalization continuously optimizes the content and offers based on user interactions, ensuring that each user receives the most relevant experience.</li></ul><p><strong>Example: Automated Personalization for an E-commerce Website</strong></p><p>Imagine a clothing and accessory reseller e-commerce website. Using Adobe Target Automated Personalization, it would be able to dynamically adjust the full user experience based on individual preferences and behaviours.</p><p>For example, if one has looked for summer dresses in the past and bought some accessories, then Adobe Target can automatically personalize a homepage banner, featured product sections, and special offers to show similar things or seasonal promotions. This works by using machine learning algorithms that look at user interactions, purchase history, and browsing patterns.</p><p>This ensures that every customer experiences the most relevant content based on their tastes and interests, hence driving higher levels of engagement and conversion. Automated Personalization puts marketers in control and allows for the delivery of a completely personalized shopping experience without manually creating multiple versions of the site for different users side by side.</p><p>To get started with Automated Personalization in Adobe Target, you can explore the <a href="https://experienceleague.adobe.com/en/docs/target/using/activities/automated-personalization/automated-personalization">Automated Personalization documentation</a>, which provides detailed guidance on setting up and optimizing personalized experiences.</p><h3><strong>Experience Targeting with Adobe Target</strong></h3><p>Experience Targeting is a feature of Adobe Target that allows marketers to deliver personalized experiences to users based on a combination of criteria, such as demographics, behaviour, and preferences. This enables marketers to tailor the content and offers to each user, improving engagement and conversion rates.</p><p><strong>How Experience Targeting Works in Adobe Target</strong></p><ul><li><strong>Audience Segmentation:</strong> Marketers create audience segments based on criteria such as demographics, behaviour, and preferences.</li><li><strong>Content Variation:</strong> Marketers create multiple variations of content, offers, or experiences tailored to each audience segment.</li><li><strong>Rules-Based Targeting:</strong> Adobe Target uses rules-based targeting to determine which content variation to deliver to each user based on their segment membership.</li><li><strong>Real-Time Optimization:</strong> Experience Targeting allows marketers to continuously optimize the content or offers based on user interactions, ensuring that each user receives the most relevant experience.</li></ul><p><strong>Benefits of Experience Targeting</strong></p><ul><li><strong>Personalization:</strong> Experience Targeting enables marketers to deliver personalized experiences to each user based on their unique characteristics and behaviours.</li><li><strong>Relevance:</strong> By delivering more relevant content and offers, marketers can increase user engagement and conversion rates.</li><li><strong>Efficiency:</strong> Experience Targeting automates the process of delivering personalized experiences, reducing the manual effort required.</li><li><strong>Flexibility:</strong> Marketers can easily create and manage audience segments and content variations, allowing for greater flexibility in targeting.</li></ul><p><strong>Example: Experience Targeting for a Health Website</strong></p><p>Let’s say you have a health website. There will be different age groups of users visiting the website. You can give personalized content based on age. Age 40+ users can be shown articles about maintaining health as they age, age 60+ users can be shown articles about senior health and wellness, and younger users can be shown articles about fitness and nutrition tips.</p><p>By using Experience Targeting in Adobe Target, you can create different experiences for each age group and determine which one resonates best with each audience segment. This level of personalization can lead to increased engagement, higher conversion rates, and ultimately, a more satisfied user base.</p><p>For setting up Experience Targeting in Adobe Target, click on “Create Activity” and select “Experience Targeting”. Select the audience required for the specific experience or variation. Save the activity and run the activity for a duration to see the results. (Longer duration yield more precise results).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8DAIc8dMrBov_E1u" /><figcaption>Targeted experience based on the “Age” of the user</figcaption></figure><h3><strong>Multivariate Testing</strong></h3><p>Multivariate testing is a technique used to test multiple variations of multiple elements on a webpage simultaneously. Unlike A/B testing, which compares two versions of a single element, multivariate testing allows you to test combinations of elements to determine the best overall design.</p><p><strong>How Multivariate Testing Works in Adobe Target</strong></p><p>In Adobe Target, setting up a multivariate test involves creating multiple variations of different elements on a webpage. For instance, you can make variations of the headline, image, and call-to-action button. Then, Adobe Target combines those variations in various ways and serves them to different segments of your audience.</p><p>By monitoring the consumer interactions with each combination, Adobe Target can track which combination yields the best result. This allows you to find the best combination for maximum effectiveness of elements to increase engagement and conversions.</p><p><strong>Example: Multivariate Testing for a Product Page</strong></p><p>Suppose you want to optimize a product page on your website. You could create variations of the product image, product description, and add-to-cart button. Adobe Target would then create different combinations of these variations and display them to users.</p><p>After running the test, you might find that a specific combination, such as a larger product image with a shorter description, results in higher conversion rates. By implementing this winning combination, you can improve the overall effectiveness of your product page.</p><p>By using multivariate testing in Adobe Target, you can fine-tune your website’s design and content to deliver a more engaging and personalized experience for your audience.</p><h3><strong>Recommendations with Adobe Target</strong></h3><p>Recommendations is a feature of Adobe Target that allows marketers to provide personalized product or content recommendations to users based on their behaviour, preferences, and other data. This helps marketers increase engagement and drive conversions by offering users relevant and timely recommendations.</p><p><strong>How Recommendations Works in Adobe Target</strong></p><ul><li><strong>Data Collection:</strong> Adobe Target collects data on user behaviour, such as pages visited, products viewed, and purchases made.</li><li><strong>Algorithmic Recommendations:</strong> Adobe Target’s machine learning algorithms analyze this data to identify patterns and trends. Based on these insights, Adobe Target automatically generates personalized recommendations for each user.</li><li><strong>Recommendation Types:</strong> Adobe Target supports various types of recommendations, including product recommendations (e.g., “Customers who bought this item also bought…”) and content recommendations (e.g., “Recommended articles for you”).</li><li><strong>Placement Options:</strong> Marketers can choose where to display the recommendations, such as on product pages, category pages, or in email campaigns.</li><li><strong>Real-Time Optimization:</strong> Recommendations are continuously optimized based on user interactions, ensuring that each user receives the most relevant recommendations.</li></ul><p><strong>Benefits of Recommendations</strong></p><ul><li><strong>Increased Engagement:</strong> Personalized recommendations can lead to higher engagement with your website or app.</li><li><strong>Improved Conversions:</strong> By offering relevant product or content recommendations, you can increase the likelihood of users making a purchase or consuming content.</li><li><strong>Enhanced User Experience:</strong> Recommendations provide users with a more personalized and satisfying experience, increasing loyalty and retention.</li></ul><p><strong>Example: Recommendations for an E-commerce Website</strong></p><p>Suppose you have an e-commerce website selling electronics. Using Recommendations in Adobe Target, you can automatically have product recommendations personalized toward each user based on their browsing and purchase history.</p><p>For example, if a user has previously purchased a laptop, Adobe Target can recommend accessories like a laptop bag or a mouse.</p><p>Recommendations in Adobe Target can help the marketer extend more relevant and interesting experiences to users, thereby allowing users to engage better and convert more.</p><p>To get started with Recommendations in Adobe Target, you can explore the <a href="https://experienceleague.adobe.com/en/docs/target/using/recommendations/recommendations">Recommendations documentation</a>, which provides comprehensive guidance on implementing and optimizing recommendations for your site.</p><h3><strong>Audience Segmentation with Adobe Target</strong></h3><p>Audience Segmentation is a feature of Adobe Target that allows marketers to divide their audience into groups based on shared characteristics or behaviours. This enables marketers to deliver more targeted and personalized experiences to each segment, improving engagement and conversion rates.</p><p><strong>Example: Audience Segmentation for an online retailer</strong></p><p>Suppose you own an e-commerce apparel and accessories store. With Audience Segmentation in Adobe Target, you can segment users based on demographics, such as age and gender, behavioural patterns, such as past purchases and browsing history, and preferences, such as style and favourite brands. For instance, you could make a segment of women aged 18–30 who have purchased dresses before and deliver recommendations to this segment for dresses and accessories.</p><p>This means that through segmentation in Adobe Target, marketers can ensure more relevant and engaging user experiences, and finally, higher engagement and conversion rates.</p><h3><strong>Geo-Targeting with Adobe Target</strong></h3><p>Geo-targeting is a feature of Adobe Target that allows marketers to deliver content or offers to users based on their geographic location. This enables marketers to provide more relevant and localized experiences to users, improving engagement and conversion rates.</p><p><strong>How Geo-Targeting Works in Adobe Target</strong></p><ul><li><strong>Location Detection:</strong> Adobe Target uses IP address or GPS data to determine the user’s geographic location.</li><li><strong>Geo-Targeted Content:</strong> Marketers can create content or offers specifically targeted to users in different locations.</li><li><strong>Real-Time Optimization:</strong> Geo-targeting allows marketers to continuously optimize the content or offers based on user location, ensuring that each user receives the most relevant experience.</li></ul><p><strong>Benefits of Geo-Targeting</strong></p><ul><li><strong>Relevance:</strong> Geo-targeting allows marketers to deliver content or offers that are relevant to users based on their location.</li><li><strong>Increased Conversions:</strong> Geo-targeted content or offers can lead to higher conversion rates as users are more likely to engage with content that is relevant to their location.</li><li><strong>Efficiency:</strong> Geo-targeting automates the process of delivering localized content, reducing the manual effort required.</li><li><strong>Localization:</strong> By delivering localized content, marketers can create a more personalized and engaging experience for users.</li></ul><p><strong>Example: Geo-Targeting for a restaurant chain</strong></p><p>An example of Geo-Targeting is say you have a chain of restaurants and you want to give discounts on selected cities. This can be achieved in Adobe Target via audience setup.</p><p>For Geo-targeting based on cities, create an activity and during the audience setup, you can choose the specific cities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uTGn6OtKkxMZCzKP" /><figcaption>Click on 3 dots and click on ‘Replace Audience’</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wmXevLyhaRyan8Rl" /><figcaption>Create a new Audience</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8sdSqHFpOMMJ-zh_" /><figcaption>Select ‘Geo’ and drop it in ‘Add attribute’</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w4dJcxWqDtq954FN" /><figcaption>Select the city and then type the city you want to target for the discounts. Click save.</figcaption></figure><p>This completes the audience setup based on Geo preference. The activity will only reflect on a selected city audience.</p><h3><strong>Conclusion</strong></h3><p>In essence, personalization should be any marketer’s main strategy when it comes to engaging their audience and increasing conversion rates. Adobe Target provides all the power and features marketers need to deliver specifically targeted experiences for your users. From A/B testing to behavioural targeting, you can be as creative as you want to make adjustments to the content, offers, or recommendations you make so they will correspond to the interests and preferences of the individual user.</p><p>Basically, with the personalization techniques available for you in Adobe Target, you can:</p><ol><li>Increase the level of user engagement and higher responsiveness with delivered content and offers.</li><li>Drive better conversion by personalizing the shopping experience.</li><li>Foster customer loyalty with the feel of knowing the customers and caring about their needs.</li></ol><p>By following such best practices and using Adobe Target to its maximum potential, such a platform will help you create better and ‘human’ experiences with your user base, resulting in better outcomes for your business.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84b0ca7be3f6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/activate-aem/personalization-techniques-with-adobe-target-84b0ca7be3f6">Personalization Techniques with Adobe Target</a> was originally published in <a href="https://medium.com/activate-aem">Activate AEM</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Node Deletion in AEM with Sling Job and Workflow]]></title>
            <link>https://medium.com/activate-aem/automating-node-deletion-in-aem-with-sling-job-and-workflow-0b92c7da9af7?source=rss----f73c4ff1649e---4</link>
            <guid isPermaLink="false">https://medium.com/p/0b92c7da9af7</guid>
            <category><![CDATA[aemasacloudservice]]></category>
            <category><![CDATA[adobe]]></category>
            <category><![CDATA[sling-jobs]]></category>
            <category><![CDATA[aem-features]]></category>
            <category><![CDATA[node-operation]]></category>
            <dc:creator><![CDATA[Varoon Kulanthaivel]]></dc:creator>
            <pubDate>Tue, 03 Sep 2024 05:29:47 GMT</pubDate>
            <atom:updated>2024-09-03T05:29:47.205Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Author: Varoon Kulanthaivel</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*dnayyu59kC7YbeKgursI9Q.jpeg" /></figure><h3>Introduction</h3><p>Managing and keeping a large-scale Adobe Experience Manager (AEM) instance often involves tasks such as cleaning up obsolete nodes. Automating such tasks can save considerable time and reduce human error. The goal is to create an automated solution for removing specific nodes in AEM based on criteria provided in the form of a payload through a CSV file. From one of the previous implementations, there were few nodes created and later when the feature was discarded, the nodes remained in the Production Environment which we wanted to delete now. This article outlines how to set up a Sling Job in AEM to automate node deletion using a workflow triggered by a CSV payload, the proposed solution will use a Sling Job Consumer and a workflow to process the CSV and trigger the node deletion.</p><h3>Context</h3><p>Automating node deletion involves several steps:</p><ol><li>Creating a Sling Job Consumer to handle the node deletion.</li><li>Setting up a workflow to trigger the Sling Job with the necessary CSV payload.</li><li>Processing the CSV to decide which nodes to remove.</li><li>The CSV will contain root path, page template and a relative path.</li></ol><p><strong>Example:</strong></p><p>Removal of an existing Spacer component from all parent pages(<em>parent_page_1, parent_page_2 ,parent_page_3</em>) which are no longer required</p><p>This can be done by removing the spacer node from all parent pages</p><p><strong>Before :</strong></p><p><em>parent_pages</em> under <em>project/language-masters/en</em> containing a Button and a Spacer component</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zCyA4e4F-4svqxyo" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XWGMy-q-FiVbCcx_" /></figure><p><strong>After :</strong></p><p>Removal of Spacer Component</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/0*jPo2iTnqSUHDJeys" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3ufZLNyZJbbW8NGL" /></figure><p><strong>Payload CSV :</strong></p><p>General</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_NjeaVh5rAj4xEcJ9ctLWA.png" /></figure><p>Specific to this Example</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2_wTyxDAXaKbJXYAyGBKpg.png" /></figure><p>In this article, we will walk through the implementation of these components, with a focus on the Sling Job Consumer and how the workflow integrates with it.</p><h3>The Sling Job Consumer</h3><p>A Sling Job Consumer plays a crucial role in processing asynchronous jobs within AEM environments. It registers itself to specific job topics, defining which tasks it can handle. Jobs are processed using the process method, which returns outcomes like success, failure, or the need for rescheduling. The advantages of using a Sling Job Consumer include efficient management of long-running tasks, enhanced system performance through asynchronous processing, and robust error handling with automatic retries.</p><p>This mechanism ensures tasks are executed at least once, even if there are failures during processing, making it essential for managing asynchronous tasks such as creating and deleting nodes, updating node properties, and sending email notifications</p><p><strong>Advantages of Using a Sling Job Consumer:</strong></p><ol><li><strong>Asynchronous Task Processing</strong>: Manages background tasks independently of the main application threads, thereby improving overall system performance.</li><li><strong>Reliable Execution</strong>: Ensures tasks are attempted at least once, leveraging persistent job states and retry mechanisms in case of failures.</li><li><strong>Error Handling and Retrying</strong>: Built-in support for handling errors ensures tasks complete reliably even under challenging conditions.</li><li><strong>Scalability</strong>: Separates job creation from execution, enabling efficient management of a large volume of tasks without impacting system responsiveness.</li><li><strong>Simplified Maintenance</strong>: Clearly defined job definitions and execution steps streamline the management of complex workflows, making the system easier to maintain.</li></ol><h3>How do we declare a Job?</h3><pre>@ConsumerType<br>public interface JobConsumer<br>@Component(service = JobConsumer.class,<br> immediate = true,<br> property = {<br> Constants.SERVICE_DESCRIPTION + “= Job Name”,<br> JobConsumer.PROPERTY_TOPICS + “=” + JobTopic<br> })</pre><h3>How do we trigger a Job?</h3><p>Every Job typically requires two key parameters:</p><ol><li><strong>TOPIC</strong>: This property is unique and assigned to a specific Job Consumer. It serves as a categorization mechanism to route jobs to the appropriate consumer capable of handling tasks related to that topic.</li><li><strong>PAYLOAD</strong>: This parameter consists of a key-value map containing serializable objects. The payload serves as the inputs or data necessary for the Job Consumer to execute its tasks.</li></ol><h3>There are 3 common ways of triggering the JobConsumer file</h3><p><strong>Workflow</strong>: Workflows in AEM are sequences of steps that automate processes like content approval, form submission handling, or any custom business process. Workflows can trigger jobs by defining steps that create or update job nodes in the JCR (Java Content Repository), specifying the job topic and payload. When a workflow step executes that triggers a job, it effectively initiates asynchronous processing by a Sling Job Consumer registered for that job topic.</p><p><strong>Servlet Trigger</strong>: A servlet in AEM can be designed to handle HTTP requests. This servlet can be configured to receive requests that include a payload, either as request parameters or in the request body. When such a request is received, the servlet can trigger a job by invoking the JobManager API or by directly adding a job node to the JCR with the appropriate job topic and payload.</p><p><strong>Scheduler</strong>: AEM allows for scheduling tasks using CRON expressions. These scheduled tasks can trigger jobs at specified intervals or at specific times. When a scheduled time is reached, AEM triggers the job, passing any necessary payload or parameters to the registered Sling Job Consumer. This enables periodic execution of tasks such as content publishing, report generation, or data synchronization.</p><p>Specific to this case, we found it possible to trigger the JobConsumer using a Workflow, as we start the Workflow to trigger the job, running only once to cleanup the nodes.</p><p>The <strong>Sling Job Consumer</strong> is a key component that handles the actual node deletion process. Given below is a Code Snippet breakdown of the essential functional parts of the <strong>NodeRemovalJobConsumer</strong> class.</p><p>CODE SNIPPET:</p><pre>public class NodeRemovalJobConsumer implements JobConsumer {<br><br>    @Reference<br>    private transient ResourceResolverFactory resolverFactory;<br><br>    @Override<br>    public JobResult process(Job job) {<br>        String payloadPath = job.getProperty(&quot;payloadPath&quot;).toString();<br>        try {<br>            ResourceResolver resourceResolver = resolverFactory.getServiceResourceResolver(null);<br>            Resource payloadResource = resourceResolver.getResource(payloadPath);<br>            Asset payloadAsset = payloadResource.adaptTo(Asset.class);<br><br>            HashMap&lt;String, String&gt; map = readCsvFile(payloadAsset);<br>            String rootPath = map.get(&quot;rootPath&quot;);<br><br>            if (rootPath != null &amp;&amp; !rootPath.isEmpty()) {<br>                AemQuery aemQuery = new AemQuery(resourceResolver);<br>                aemQuery.inPath(rootPath).byType(&quot;cq:PageContent&quot;).byProperty(&quot;cq:template&quot;, map.get(&quot;template&quot;)).limitTo(-1);<br>                Optional&lt;SearchResult&gt; searchResult = aemQuery.query();<br><br>                if (searchResult.isPresent()) {<br>                    Iterator&lt;Resource&gt; resources = searchResult.get().getResources();<br>                    Session session = resourceResolver.adaptTo(Session.class);<br>                    while (resources.hasNext()) {<br>                        Resource resource = resources.next();<br>                        Resource relativeResource = resourceResolver.getResource(resource.getPath() + map.get(&quot;relativePath&quot;));<br>                        if (relativeResource != null) {<br>                            resourceResolver.delete(relativeResource);<br>                            session.save();<br>                        }<br>                    }<br>                }<br>            }<br>            return JobResult.OK;<br>        } catch (Exception e) {<br>            return JobResult.FAILED;<br>        }<br>    }<br>}</pre><h3>Key Components</h3><ul><li><strong>Job Topic</strong>: The job topic is defined as node_removal/job. This is the identifier for the job that the workflow will trigger.</li><li><strong>Resource Resolver</strong>: Utilized to gain access to the AEM resources.</li><li><strong>CSV Parsing</strong>: The readCsvFile method is used to read and parse the CSV file to get the required data for node deletion.</li><li><strong>AEM Query</strong>: AemQuery is used to search for nodes based on criteria specified in the CSV.</li><li><strong>Node Deletion</strong>: The nodes identified by the query are deleted.</li></ul><h3>Triggering the Job with a Workflow</h3><p>The workflow initiates the Sling Job using the CSV payload. Here’s an overview of the JobProducerWorkflowProcess class, which is responsible for triggering the job.</p><p>CODE SNIPPET :</p><pre>@Component(<br>    immediate = true,<br>    service = WorkflowProcess.class,<br>    property = {<br>        &quot;service.description=Trigger Job Consumers&quot;,<br>        &quot;process.label=Trigger Job Consumers&quot;<br>    }<br>)<br>public class JobProducerWorkflowProcess implements WorkflowProcess {<br>    @Reference<br>    private JobManager jobManager;<br><br>    @Override<br>    public void execute(WorkItem item, WorkflowSession session, MetaDataMap args) throws WorkflowException {<br>        String payloadType = item.getWorkflowData().getPayloadType();<br>        String metaArgs = args.get(&quot;PROCESS_ARGS&quot;, String.class);<br><br>        final Map&lt;String, Object&gt; props = new HashMap&lt;&gt;();<br>        if (StringUtils.equals(payloadType, &quot;JCR_PATH&quot;)) {<br>            String path = item.getWorkflowData().getPayload().toString();<br>            props.put(&quot;payloadPath&quot;, path);<br>        }<br>        jobManager.addJob(metaArgs, props);<br>    }<br>}</pre><h3>Key Components</h3><ul><li><strong>JobManager</strong>: The JobManager service is used to create and manage jobs. The addJob method is called to add a new job to the queue.</li><li><strong>Workflow Process Execution</strong>: The execute method is the entry point for the workflow process. It reads the payload and arguments, and then triggers the job.</li><li><strong>Payload Handling</strong>: The workflow process extracts the payload path from the WorkItem and adds it to the job properties.</li></ul><h3>How the Workflow Uses Payload</h3><ol><li><strong>CSV Upload</strong>: The CSV file is uploaded to a specific path in the DAM.</li><li><strong>Workflow Launch</strong>: A workflow is triggered upon the upload of the CSV.</li><li><strong>Job Creation</strong>: The workflow creates a job with the topic node_deletion/job and includes the path of the uploaded CSV as a payload.</li><li><strong>Job Processing</strong>: The NodeRemovalJobConsumer processes the job and deletes the nodes as specified in the CSV.</li></ol><h3>Conclusion</h3><p>By automating node deletion using a Sling Job and workflow in AEM, you can streamline maintenance tasks and reduce the risk of human error. This approach leverages the flexibility of AEM and the power of automated jobs to keep your content repository clean and organized. Implementing this solution involves setting up the job consumer, parsing the CSV payload, and integrating it with a workflow for seamless operation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0b92c7da9af7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/activate-aem/automating-node-deletion-in-aem-with-sling-job-and-workflow-0b92c7da9af7">Automating Node Deletion in AEM with Sling Job and Workflow</a> was originally published in <a href="https://medium.com/activate-aem">Activate AEM</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancing AEM Lucene Search: Advanced Techniques for Improved Search Functionality : Final Part]]></title>
            <link>https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-final-part-e6738e9e7292?source=rss----f73c4ff1649e---4</link>
            <guid isPermaLink="false">https://medium.com/p/e6738e9e7292</guid>
            <category><![CDATA[search]]></category>
            <category><![CDATA[lucene]]></category>
            <category><![CDATA[aem-developer]]></category>
            <category><![CDATA[aem]]></category>
            <category><![CDATA[adobe-experience-manager]]></category>
            <dc:creator><![CDATA[Kiran Mayee N]]></dc:creator>
            <pubDate>Tue, 13 Aug 2024 04:03:36 GMT</pubDate>
            <atom:updated>2024-08-13T04:03:35.663Z</atom:updated>
            <content:encoded><![CDATA[<h3>Enhancing AEM Lucene Search: Advanced Techniques for Improved Search Functionality : Final Part</h3><p><strong>Welcome back, AEM enthusiasts!</strong></p><p>We’ve tackled the challenges of indexing management and crafted user-friendly search results with excerpts and highlighting. But what if users struggle to find the perfect search terms, or encounter those inevitable typos?</p><p>This article dives into the realm of advanced AEM search functionalities — synonyms, filters, and spell check. We’ll explore how these features empower users to refine their searches and navigate content with greater ease. Imagine a search experience that understands synonyms, helps filter through specific criteria, and even corrects typos on the fly — all leading to a more efficient and frustration-free journey for your users.</p><p><strong>Building on a Strong Foundation</strong></p><p>This article assumes you’ve read the previous installments in our AEM search optimization series. If you haven’t yet, we recommend starting with “Enhancing AEM Lucene Search: Advanced Techniques for Improved Search Functionality” Series to ensure your search engine has a solid foundation.</p><p><strong>Previously Covered in this series:</strong></p><ul><li><strong>Search Suggestion Servlets</strong></li></ul><p><a href="https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-part-1-effbbc4ab5e9">Enhancing AEM Lucene Search: Advanced Techniques for Improved Search Functionality- Part 1</a></p><ul><li><strong>Optimizing Search with AEM Indexing Management</strong></li></ul><p><a href="https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-part-2-d8c66b59c1ef">Enhancing AEM Lucene Search: Advanced Techniques for Improved Search Functionality : Part 2</a></p><ul><li><strong>Craft Compelling Search Results: Highlighting Keywords &amp; Controlled Excerpts</strong></li></ul><p><a href="https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-part-3-dff0fa1a5e52">Enhancing AEM Lucene Search: Advanced Techniques for Improved Search Functionality : Part 3</a></p><p>Now, let’s unlock the full potential of AEM search with these powerful functionalities!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LJaouKmgR6dr8Fu3X3waQg.png" /></figure><h3>Empower User Searches: Synonyms, Filters &amp; Spell Check</h3><p>Imagine searching for “sneakers” and finding results not just for that exact term, but also for “trainers” and “athletic shoes.” This is the magic of synonyms in search.</p><p><strong>Synonyms: Expanding the Search Net</strong></p><p>When you enter a search query, the system doesn’t just look for that specific word. It also considers synonyms — words with similar meanings. This broadens the search scope, ensuring you find content even if you don’t use the exact terminology used in the content itself. These words could be defined in the “<em>Synonyms.txt</em>” file in the Index, as shown in the <a href="https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-part-2-d8c66b59c1ef#bba6">Index Management Article</a> (Part 2 : Section <strong>4.3.3 </strong>in this series).</p><p>Eg:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KqTYFzbwVoeXyCaH" /></figure><p>Here though, my Fulltext Search Query Term is “<em>Pharmaceuticals</em>”. It still includes results that contain the word “<em>Pharmacy</em>” too. Since the same is configured in my Synonyms.txt file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/0*XJCzCFApVls1hVPT" /></figure><p>Search systems don’t stop at synonyms. They can also dynamically extract filters based on your query. This means the search itself suggests potential ways to refine your results and pinpoint exactly what you’re looking for.</p><p><strong>Dynamic Filters: Refining Your Search Journey</strong></p><p>Here’s a simplified illustration:</p><p>Imagine searching for “hiking trails.” The system might automatically identify filters like “region,” “difficulty level,” or “length” based on the query and the content available. You can then use these filters to narrow down your search and find the perfect hiking trail for your needs.</p><p>Learn more about: <a href="https://lucene.apache.org/core/4_0_0/facet/org/apache/lucene/facet/doc-files/userguide.html">Lucene Faceted Search</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*STqWJ6FECGeb6Ut0" /></figure><p>AEM allows you to extract filters dynamically based on search queries, enhancing the user experience by suggesting relevant ways to refine their search. Here’s a breakdown of how you might achieve this using Java code:</p><p>Identifying Filter Categories:</p><p>The first step involves identifying potential filter categories based on your search query and content structure. This can be achieved through:</p><ul><li><strong>Predefined Rules:</strong> Define rules that map specific terms or patterns within the query to filter categories. For example, terms like “location” or “city” might trigger the “region” filter category.</li><li><strong>Taxonomy Analysis:</strong> If you utilize taxonomies within your content, analyze the query against the taxonomy structure to identify relevant categories.</li></ul><p>Bucket-based Approach:</p><p>One common approach for filter extraction involves using buckets:</p><ul><li><strong>Bucket Creation:</strong> As the search results are processed, create buckets for each identified filter category. Each bucket will hold information about the specific filter options within that category (e.g., different regions or topics).</li><li><strong>Populating Buckets:</strong> Iterate through the search results and analyze the content based on your predefined rules or taxonomy mapping. When a relevant term is encountered, add it to the corresponding bucket. For example, if the content mentions “California,” it would be added to the “region” bucket with the value “California.”</li></ul><p>Processing Bucket Data:</p><p>Once you have populated the buckets with relevant filter options:</p><ul><li><strong>Create Filter Data Structures:</strong> Iterate through each bucket and construct the data structure representing the filter category and its available options. This might involve creating JSON objects or other data structures suitable for your chosen UI framework.</li><li><strong>Handle Duplicates:</strong> You might want to remove duplicate entries within each filter category to provide a cleaner user experience. Utilize helper methods to identify and eliminate duplicates based on your specific needs.</li></ul><p><strong>Code Example 1:</strong></p><pre>// Assuming a Bucket class exists to hold filter options<br>public void extractFilters(SearchResult result, List&lt;String&gt; filterCategories, Map&lt;String, Bucket&gt; filterMap) {<br>  // Analyze query and content to identify relevant filter categories<br>  for (String category : filterCategories) {<br>    Bucket bucket = new Bucket(category);<br>    // (Logic to populate bucket based on predefined rules or taxonomy analysis)<br>    filterMap.put(category, bucket);<br>  }<br><br>  // Process content within search results<br>  List&lt;ContentNode&gt; contentNodes = result.getContentNodes();<br>  for (ContentNode node : contentNodes) {<br>    // (Logic to analyze content and add relevant information to buckets)<br>  }<br><br>  // Construct filter data structures and handle duplicates (implementation details omitted)<br>}</pre><p><strong>Code Example 2: </strong>where “1_group.1_property”<strong> </strong>is a predicate used in the Query</p><pre>Map&lt;String, Facet&gt; facets = result.getFacets();<br><br>if (facets.containsKey(&quot;1_group.1_property&quot;)) {<br>                            facets.get(&quot;1_group.1_property&quot;).getBuckets().forEach(bucket -&gt; getFacetData(bucket, topicData, difficultyLevel, filterData,<br>                                    heading, filterData1, heading1));<br>                        }<br>                        <br> private void getFacetData(Bucket bucket, List&lt;Tag&gt; topicData, List&lt;Tag&gt; difficultyLevel,<br>                              JSONArray filterData, JSONObject heading, JSONArray filterData1, JSONObject heading1) {<br>        try {<br>            Tag tagName = tagManager.resolve(bucket.getValue());<br>            // (Logic to analyze content and add relevant information to buckets)<br>        } catch (JSONException jsonException) {<br>            LOG.error(&quot;JSON exception when adding to Json Object, {}&quot;,<br>                    jsonException.getMessage());<br>        }<br>    }     </pre><p><strong>Important Note:</strong></p><p>This is a simplified illustration, and the actual implementation will depend on your specific AEM setup, content structure, and desired filter options. The key aspects involve identifying filter categories, populating buckets, and constructing the final filter data structure.</p><p><strong>Benefits of Synonyms and Dynamic Filters:</strong></p><ul><li><strong>More Comprehensive Results:</strong> Synonyms prevent you from missing relevant content simply because you didn’t use the exact keyword.</li><li><strong>Enhanced Search Accuracy:</strong> Dynamic filters help you refine your search journey, leading to more precise and focused results.</li><li><strong>Improved User Experience:</strong> By understanding your intent and suggesting relevant filters, the search system empowers you to navigate information efficiently.</li></ul><p><strong>Fun Fact!</strong></p><p>We can actually see the facets that could be extracted for a particular set of results in the Query Builder Debugger Tool too. By Selecting the ‘Extract facets’ Checkbox as shown in the below Video. Reference : <a href="https://youtu.be/__lz5d7-94M?si=dEe6e1SRkf888egK">AEM QueryBuilder Demo Part 2 — Facets</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bh7B4ASarM7n08Tl" /></figure><p><strong>Spell Check Activation:</strong></p><p>Ever typed a search query and ended up with unexpectedly zero results? Typos happen, and they can be frustrating when navigating search systems. Thankfully, AEM’s spell check functionality can come to the rescue!</p><p><strong>What is Spell Check Activation?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/309/0*cUzbdlTEkeAflukR" /></figure><p>Spell Check activation is a feature that helps users overcome typos and misspellings in their search queries. When enabled, the search system leverages a spellchecker to analyze the query for potential errors. If a misspelling is detected, the system suggests corrected terms, allowing users to refine their search and find the information they need more efficiently.</p><p><strong>Code Example 1:</strong></p><pre>import org.apache.lucene.search.spell.SpellChecker;<br><br>public class SearchService {<br><br>    private final SpellChecker spellChecker;<br><br>    public SearchService(SpellChecker spellChecker) {<br>        this.spellChecker = spellChecker;<br>    }<br><br>    public SearchResult executeSearch(String query, boolean enableSpellcheck) throws IOException {<br>        String correctedQuery = query;<br>        if (enableSpellcheck) {<br>            Set&lt;String&gt; suggestions = spellChecker.suggestSimilar(query, 5);<br>            if (!suggestions.isEmpty()) {<br>                correctedQuery = suggestions.iterator().next();<br>            }<br>        }<br>        // Perform search using the corrected query<br>        return performSearch(correctedQuery);<br>    }<br><br>    // Implementation for performSearch(...) to execute the search with the corrected query<br>}</pre><p><strong>Code Example 2:</strong></p><pre>import com.day.cq.search.suggest.Suggester;<br><br>@Inject<br>private Suggester suggester;<br>    <br>private Session session;<br><br>public String searchWithSpellcheck(ResourceResolver resolver, String fullTextQuery, int limit, int offset) throws IOException {<br>    if (isSpellCheckEnabled()) {<br>        String correctedQuery = spellCheckQuery(fullTextQuery);<br>        return correctedQuery != null ? getResults(limit, offset, correctedQuery) : getResults(limit, offset, fullTextQuery);<br>    } else {<br>        return getResults(limit, offset, fullTextQuery);<br>    }<br>}<br><br>private String spellCheckQuery(String fullTextQuery) {<br>    StringJoiner correctedWords = new StringJoiner(&quot; &quot;);<br>    for (String word : fullTextQuery.split(&quot; &quot;)) {<br>        String suggestion = suggester.spellCheck(session, word);<br>        correctedWords.add(suggestion != null ? suggestion : word);<br>    }<br>    return correctedWords.toString();<br>}</pre><p><strong>Important Note:</strong></p><p>This is a simplified illustration, and the actual implementation will depend on your specific AEM setup, content structure and code etc.</p><p>Congratulations! You’ve reached the final chapter in our exploration of AEM Lucene Search optimization. Throughout this series, we’ve covered a range of techniques to empower users and elevate the overall search experience:</p><ul><li><strong>Search Suggestion Servlets:</strong> We briefly introduced the concept of search suggestion servlets, highlighting their ability to guide users towards relevant content through real-time suggestions.</li><li><strong>Optimizing Search with AEM Indexing Management:</strong> We laid the groundwork by understanding the importance of efficient indexing for accurate and speedy search results.</li><li><strong>Craft Compelling Search Results: Highlighting Keywords &amp; Controlled Excerpts:</strong> We explored how keyword highlighting and excerpts can transform search results into user-friendly snippets, saving users valuable time.</li><li><strong>Empower User Searches: Synonyms, Filters &amp; Spell Check:</strong> We unveiled advanced functionalities like synonyms, filters, and spell check, allowing users to refine their searches with greater precision.</li></ul><p><strong>By leveraging these enhancements for AEM Lucene Search, organizations can significantly optimize search functionality and deliver superior user experiences.</strong> As AEM developers and administrators, we can tailor search experiences that perfectly align with the unique needs of our digital properties.</p><p>Remember, the journey towards an exceptional AEM search experience is a continuous one. AEM Lucene Search remains a powerful tool that can evolve alongside your website, fostering content discoverability, user engagement, and ultimately, a successful digital presence.</p><p><strong>Happy searching, and keep exploring the possibilities!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6738e9e7292" width="1" height="1" alt=""><hr><p><a href="https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-final-part-e6738e9e7292">Enhancing AEM Lucene Search: Advanced Techniques for Improved Search Functionality : Final Part</a> was originally published in <a href="https://medium.com/activate-aem">Activate AEM</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancing AEM Lucene Search: Advanced Techniques for Improved Search Functionality : Part 3]]></title>
            <link>https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-part-3-dff0fa1a5e52?source=rss----f73c4ff1649e---4</link>
            <guid isPermaLink="false">https://medium.com/p/dff0fa1a5e52</guid>
            <category><![CDATA[aem]]></category>
            <category><![CDATA[lucene]]></category>
            <category><![CDATA[aem-developer]]></category>
            <category><![CDATA[search]]></category>
            <category><![CDATA[adobe-experience-manager]]></category>
            <dc:creator><![CDATA[Kiran Mayee N]]></dc:creator>
            <pubDate>Tue, 30 Jul 2024 14:16:53 GMT</pubDate>
            <atom:updated>2024-07-30T14:16:52.719Z</atom:updated>
            <content:encoded><![CDATA[<h3>Enhancing AEM Lucene Search: Advanced Techniques for Improved Search Functionality : Part 3</h3><p><strong>Hey there, AEM users!</strong></p><p>You’ve conquered the initial search hurdle — you’ve found the relevant content! But sifting through lengthy content previews can still be time-consuming. What if you could instantly identify the information you need?</p><p>This article dives into the world of crafting compelling search results on AEM. We’ll explore features like keyword highlighting and controlled excerpts, designed to make your search experience efficient and user-friendly. Imagine finding the exact answer you seek within seconds, thanks to highlighted keywords that pinpoint the most relevant sections of the content.</p><p><strong>Building on a Strong Foundation</strong></p><p>This article assumes you’ve read the previous installments in our AEM search optimization series. If you haven’t yet, we recommend starting with “Optimizing Search with AEM Indexing Management” to ensure your search engine has a solid foundation of well-indexed content.</p><p><strong>Upcoming Article in this Series!</strong></p><ul><li><strong>Empower User Searches: Synonyms, Filters &amp; Spell Check :</strong> Expanding search capabilities to include synonyms and filters, and helping users out with those pesky typos.</li></ul><p><strong>Previously Covered in this series:</strong></p><ul><li><a href="https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-part-1-effbbc4ab5e9">Search Suggestion Servlets</a></li></ul><p><a href="https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-part-1-effbbc4ab5e9">Enhancing AEM Lucene Search: Advanced Techniques for Improved Search Functionality- Part 1</a></p><ul><li><a href="https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-part-2-d8c66b59c1ef">Optimizing Search with AEM Indexing Management</a></li></ul><p><a href="https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-part-2-d8c66b59c1ef">Enhancing AEM Lucene Search: Advanced Techniques for Improved Search Functionality : Part 2</a></p><p>Now, let’s get started on crafting search results that truly impress!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WFSZJjcXHrhXA_j6Y7Jiiw.png" /></figure><h3>Craft Compelling Search Results: Highlighting Keywords &amp; Controlled Excerpts</h3><p>Imagine searching for a specific topic within your AEM website. Highlighting the search terms within the results is helpful, but wouldn’t it be even better to see a surrounding snippet of text providing context? This is where excerpts come in.</p><p><strong>Excerpts and Keyword Highlighting within</strong></p><p>Excerpts are brief text passages extracted from the content around the matched keywords. By displaying excerpts alongside search results, you offer users a glimpse into the content’s relevance without requiring them to visit every single page. This can significantly improve the search experience by:</p><ul><li><strong>Providing Context:</strong> Users can quickly understand how the search term is used within the content, improving their ability to judge relevance at a glance.</li><li><strong>Saving Time:</strong> By previewing the content, users can determine if a specific result meets their needs without needing to navigate to the full page.</li><li><strong>Enhancing Engagement:</strong> A more informative search experience keeps users engaged and focused on finding the information they seek.</li></ul><p><strong>Enabling Excerpts in AEM</strong></p><p>Adobe Experience Manager (AEM) provides two primary methods for utilizing excerpts in search results:</p><p><strong>1. p.excerpt in Query Predicates (Limited Functionality)</strong></p><ul><li>p.excerpt refers to the ability to include excerpts of matching content in search results.</li><li>However, in current versions of AEM, enabling p.excerpt in query predicates might not directly display excerpts within the search results themselves until hit.getExcerpt is used to extract the Excerpt.</li><li>The documented behavior might be outdated or specific to certain AEM configurations or debugging tools like the Query Builder debugger shown below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kJYQH2m7q9darMC9" /></figure><p><strong>Disclaimer:</strong></p><p>While my testing suggests limitations with p.excerpt in conjunction with hit.getExcerpt led to redundant result hits programmatically and slower server response times.</p><p>It’s important to acknowledge that others might have different experiences or AEM configurations that yield different results. If you have a different perspective on p.excerpt functionality, please share your insights!</p><p><strong>2. hit.getExcerpt Method (Recommended Approach):</strong></p><ul><li>When reading search results programmatically, developers can use the <em>hit.getExcerpt()</em> method to retrieve the excerpt of the matched content directly from the search result object.</li><li>This method allows developers to programmatically access and display excerpts in custom search result templates or components.</li></ul><p>Example 1 using <strong>p.excerpt=true</strong></p><pre>2_group.fulltext = keyword<br>2_group.p.or = true<br>9_orderby = orderbydate<br>9_orderby.sort = desc<br>group.1_group.property = sling:resourceType<br>group.1_group.property.1_value = generic-company/components/content/article<br>group.1_group.type = nt:unstructured<br>group.2_group.property = jcr:content/sling:resourceType<br>group.2_group.property.value = generic-company/components/structure/page/basepage<br>group.2_group.type = cq:Page<br>group.p.or = true<br>p.facets = true<br>p.limit = 10<br>p.offset = 0<br>p.excerpt = true<br>path = /content/generic-company/content/</pre><p>Example 2 using <strong>hit.getExcerpt</strong></p><pre>private static Map&lt;String, Object&gt; addOtherData(final Hit hit, Map&lt;String, Object&gt; map)<br>    throws RepositoryException {<br>  final Resource resource = hit.getResource();<br>  final ValueMap properties = resource.adaptTo(ValueMap.class);<br>  map.put(CF_PATH, resource.getPath());<br>  map.put(CF_NAME, resource.getName());<br>  map.put(CF_TITLE, properties.get(&quot;jcr:title&quot;, resource.getName()));<br>  map.put(CF_EXCERPT, hit.getExcerpt());<br>  map.put(CF_LAST_MODIFIED, getLastModified(resource));<br>  map.put(CF_TYPE, &quot;Data&quot;);<br>  return map;<br>}</pre><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gCRiXN8H8u2GolyeGMgTdg.png" /></figure><p><strong>Explanation:</strong></p><p>The excerpt generation process in AEM involves highlighting the matched keywords within the retrieved content. AEM automatically generates excerpts for search results, and it includes HTML markup to highlight the matched keywords, typically using &lt;strong&gt; tags. This highlighting method visually distinguishes the matched keywords within the excerpts, making it easier for users to identify relevant content snippets.</p><p>Ever searched for something online and ended up with results that felt incomplete or irrelevant? One reason for this can be generic excerpts that don’t accurately reflect the content’s core message. Thankfully, AEM’s Controlled Excerpt Properties offer a solution.</p><p><strong>Controlled Excerpt Properties:</strong></p><p><strong>What are Controlled Excerpt Properties?</strong></p><p>This feature empowers you to customize the properties used to generate excerpts displayed alongside search results. By specifying which properties to consider — like title, description, or custom fields — you can significantly improve the relevance and user experience of your AEM search.</p><p><strong>Benefits of Controlled Excerpt Properties:</strong></p><ul><li><strong>Enhanced Relevance:</strong> Users can quickly grasp the content’s focus by seeing relevant excerpts that highlight the search term within the context of specific properties. This helps them determine if a result is truly what they’re looking for, saving them valuable time and clicks.</li><li><strong>Improved User Experience:</strong> More informative excerpts lead to a more engaging search experience. Users can make informed decisions about which results to explore further based on the preview provided by the excerpt.</li><li><strong>Greater Control:</strong> You have the power to define which properties best represent the content and showcase the search term’s relevance. This level of control ensures excerpts accurately reflect your content and user needs.</li></ul><p><strong>How to Define Excerpt Properties:</strong></p><p>AEM utilizes the <em>com.day.cq.search.impl.builder.QueryBuilderImpl.cfg.json</em> file to configure various search functionalities. Within this file, you can define the properties you want to use for generating excerpts by specifying them under the “<em>excerpt.properties</em>” key. Here’s an example:</p><pre>{<br>    &quot;excerpt.properties&quot;: [<br>        &quot;jcr:description&quot;,<br>        &quot;text&quot;,<br>        &quot;jcr:title&quot;,<br>        &quot;bodyText&quot;<br>    ]<br>}<br><br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8eSTBIUkTyl7-BX9" /></figure><p>In this example, the excerpt will be generated by pulling text from the jcr:description, text, jcr:title, and bodyText properties of the content items.</p><p><strong>Happy searching! Excerpts and highlighted keywords are a powerful combo for user-friendly AEM search results. Stay tuned for the last article in this series “Empower User Searches: Synonyms, Filters &amp; Spell Check”!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dff0fa1a5e52" width="1" height="1" alt=""><hr><p><a href="https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-part-3-dff0fa1a5e52">Enhancing AEM Lucene Search: Advanced Techniques for Improved Search Functionality : Part 3</a> was originally published in <a href="https://medium.com/activate-aem">Activate AEM</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancing AEM Lucene Search: Advanced Techniques for Improved Search Functionality : Part 2]]></title>
            <link>https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-part-2-d8c66b59c1ef?source=rss----f73c4ff1649e---4</link>
            <guid isPermaLink="false">https://medium.com/p/d8c66b59c1ef</guid>
            <category><![CDATA[lucene]]></category>
            <category><![CDATA[search]]></category>
            <category><![CDATA[aem]]></category>
            <category><![CDATA[aem-developer]]></category>
            <category><![CDATA[adobe-experience-manager]]></category>
            <dc:creator><![CDATA[Kiran Mayee N]]></dc:creator>
            <pubDate>Thu, 18 Jul 2024 15:50:27 GMT</pubDate>
            <atom:updated>2024-07-30T16:44:08.090Z</atom:updated>
            <content:encoded><![CDATA[<h3>Enhancing AEM Lucene Search: Advanced Techniques for Improved Search Functionality : Part 2</h3><p><strong>Hey there, AEM users!</strong></p><p>Struggling to find the content you need on your AEM site? Ever felt like you’re searching for a needle in a haystack? We’ve all been there. But fret no more! This series of blog posts is your guide to a supercharged AEM search experience.</p><p>We’ll be diving into some cool features that will make finding content a breeze. Think lightning-fast results, real-time suggestions as you type, and even highlighted keywords to pinpoint what you need instantly.</p><p><a href="https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-part-1-effbbc4ab5e9">In our previous article</a>, we explored the magic of search suggestion servlets — those helpful prompts that appear as you type, guiding you towards the content you crave. Now, let’s shift gears and focus on the foundation of a great search experience: AEM indexing management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IloC17eiFXSruHuNwv0fBA.png" /></figure><h3><strong>Optimizing Search with AEM Indexing Management</strong></h3><p>This article equips you with the knowledge to optimize your AEM search for accuracy, efficiency, and user satisfaction. We’ll delve into the core concepts of indexing management and explore best practices to keep your search results on point, even with a massive amount of content.</p><p><strong>Stay tuned for more!</strong></p><p>This series is just getting started. In the coming weeks, we’ll be exploring:</p><ul><li><a href="https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-part-3-dff0fa1a5e52"><strong>Craft Compelling Search Results: Highlighting Keywords &amp; Controlled Excerpts</strong></a><strong> :</strong> Making your search results super user-friendly by highlighting keywords and showing only the most relevant info.</li><li><strong>Empower User Searches: Synonyms, Filters &amp; Spell Check :</strong> Expanding search capabilities to include synonyms and filters, and helping users out with those pesky typos.</li></ul><p><strong>Previously Covered in this series:</strong></p><ul><li><a href="https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-part-1-effbbc4ab5e9">Search Suggestion Servlets</a></li></ul><p><a href="https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-part-1-effbbc4ab5e9">Enhancing AEM Lucene Search: Advanced Techniques for Improved Search Functionality- Part 1</a></p><h3>Index Management</h3><p>A fundamental aspect of Adobe Experience Manager (AEM) is its indexing management, which plays a pivotal role in optimizing content search capabilities within the platform. Effective indexing is essential for ensuring that users can quickly retrieve relevant content. AEM’s indexing management revolves around various strategies aimed at enhancing the search experience.</p><p>Key components of AEM indexing management include:</p><ol><li><strong>Relevant Properties Inclusion:</strong></li></ol><p>AEM indexing management prioritizes the inclusion of relevant properties in the index. By selectively indexing properties that are crucial for search relevance, AEM ensures that search results are accurate and meaningful.</p><p><strong>Sample Index:</strong></p><pre>&lt;indexRules jcr:primaryType=&quot;nt:unstructured&quot;&gt;<br>                &lt;nt:unstructured<br>                        jcr:primaryType=&quot;nt:unstructured&quot;<br>                        includePropertyTypes=&quot;[String]&quot;&gt;<br>                        &lt;properties jcr:primaryType=&quot;nt:unstructured&quot;&gt;<br>                                &lt;hideInNav<br>                                        jcr:primaryType=&quot;nt:unstructured&quot;<br>                                        index=&quot;{Boolean}false&quot;<br>                                        name=&quot;hideInNav&quot; /&gt;<br>                                &lt;offTime<br>                                        jcr:primaryType=&quot;nt:unstructured&quot;<br>                                        index=&quot;{Boolean}false&quot;<br>                                        name=&quot;offTime&quot; /&gt;<br>                                &lt;onTime<br>                                        jcr:primaryType=&quot;nt:unstructured&quot;<br>                                        index=&quot;{Boolean}false&quot;<br>                                        name=&quot;onTime&quot; /&gt;<br>                                &lt;allowedTemplates<br>                                        jcr:primaryType=&quot;nt:unstructured&quot;<br>                                        index=&quot;{Boolean}false&quot;<br>                                        name=&quot;cq:allowedTemplates&quot; /&gt;<br>                                &lt;childrenOrder<br>                                        jcr:primaryType=&quot;nt:unstructured&quot;<br>                                        index=&quot;{Boolean}false&quot;<br>                                        name=&quot;cq:childrenOrder&quot; /&gt;<br>                                &lt;designPath<br>                                        jcr:primaryType=&quot;nt:unstructured&quot;<br>                                        index=&quot;{Boolean}false&quot;<br>                                        name=&quot;cq:designPath&quot; /&gt;<br>                                &lt;resourceType<br>                                        jcr:primaryType=&quot;nt:unstructured&quot;<br>                                        name=&quot;sling:resourceType&quot;<br>                                        propertyIndex=&quot;{Boolean}true&quot;<br>                                        weight=&quot;{Long}0&quot; /&gt;<br>                                &lt;resourceSuperType<br>                                        jcr:primaryType=&quot;nt:unstructured&quot;<br>                                        name=&quot;sling:resourceSuperType&quot;<br>                                        propertyIndex=&quot;{Boolean}true&quot;<br>                                        weight=&quot;{Long}0&quot; /&gt;<br>                                &lt;prop<br>                                        jcr:primaryType=&quot;nt:unstructured&quot;<br>                                        analyzed=&quot;{Boolean}true&quot;<br>                                        isRegexp=&quot;{Boolean}true&quot;<br>                                        name=&quot;^[^\\/]*$&quot;<br>                                        nodeScopeIndex=&quot;{Boolean}true&quot;<br>                                        useInExcerpt=&quot;{Boolean}true&quot; /&gt;<br>                                &lt;textField<br>                                        jcr:primaryType=&quot;nt:unstructured&quot;<br>                                        boost=&quot;{Decimal}0.01&quot;<br>                                        index=&quot;{Boolean}true&quot;<br>                                        name=&quot;textField&quot; /&gt;<br>                        &lt;/properties&gt;<br>                &lt;/nt:unstructured&gt;<br>        &lt;/indexRules&gt;</pre><p>1.1 <strong>propertyIndex:</strong></p><ul><li>The <strong>propertyIndex</strong> attribute determines whether a property should be included in the Lucene index. When set to true (like with sling:resourceType and sling:resourceSuperType in our example), <strong>the property’s values are incorporated into the index</strong> and become searchable.</li><li>Properties like hideInNav likely have a dedicated attribute named <strong>index set to false to exclude them from indexing</strong>. The propertyIndex attribute is specifically used for properties you want to manage within the context of AEM indexing, allowing you to control their searchability.</li></ul><p>1.2 <strong>weight:</strong></p><ul><li>The <strong>weight</strong> attribute is used in conjunction with the <strong>propertyIndex </strong>attribute for properties of type sling:resourceType and sling:resourceSuperType. It allows you to specify a <strong>significance value for these properties</strong> within the search ranking.</li><li>In the provided configuration, both sling:resourceType and sling:resourceSuperType have a weight=”{Long}0&quot; setting. This means they are included in the index (propertyIndex=”{Boolean}true”) but aren’t given any extra weight in the ranking algorithm (weight=”{Long}0&quot;). Setting the weight to 0 explicitly communicates our intent. It clarifies that these properties, while indexed, shouldn’t receive any additional weight in the ranking algorithm beyond Lucene’s potential default boost (often 1.0).</li><li>Sets a baseline significance for the entire property within search ranking. It acts as a multiplier for the property’s overall influence.</li><li><em>Example:</em> A weight of 2 for the brand property indicates that documents matching the brand term will be considered twice as important as those matching description or price terms (assuming weight 1). This can significantly influence ranking even if terms aren’t boosted within the property.</li></ul><p>1.3 <strong>boost:</strong></p><ul><li>In AEM indexes built upon Lucene, <strong>boost</strong> is a factor assigned to a specific property or field that influences its importance during the search process. Properties with a higher boost value are considered more relevant by the search engine and will be ranked higher in search results.</li><li>In the provided configuration, you’ll see the boost attribute used with the textField property here. Each of these has a boost=”{Decimal}0.01&quot; setting. This indicates that content matching these properties will receive a slight increase in ranking compared to other properties without a boost.</li><li>This <strong>influences the importance of individual terms extracted from the property value</strong> during indexing. However, it’s not explicitly defined in the configuration.The boost value we set for the entire property in the AEM configuration (e.g., “boost=0.5” for the title property) might be applied to these individual terms created by Lucene during tokenization.</li></ul><h4>Understanding the Nuances of Boost and Weight</h4><p><strong>Key Differences:</strong></p><ul><li><em>Granularity:</em> Boost applies to individual terms within a property, increases/decreases importance of individual terms, while Weight applies to the entire property, Sets baseline significance for the entire property.</li><li><em>Customization:</em> Boost allows for more granular control over the importance of specific terms. Weight focuses on the overall significance of a property.</li></ul><h4>Scenario</h4><p>Imagine we have an e-commerce site with products that have properties like title, description, brand, and price. We want to prioritize searches based on title and brand while considering descriptions and price to some extent.</p><p><em>Boost:</em></p><p>Boosting Titles: We can assign a boost to the title property. Let’s say a boost of 0.5. This means terms found in the product title will have a significant impact on the search score. A product with a title that exactly matches the search term will rank higher compared to products where the term only appears in the description.</p><p>Example: Search Term: “Running shoes”</p><ul><li>Product A: Title: “Nike Running Shoes — Zoom Pegasus”, Description: “Comfortable running shoes…” (Boost applied to Title)</li><li>Product B: Title: “Everyday Sneakers”, Description: “These shoes are great for running…”</li></ul><p>In this case, Product A would likely rank higher because the search term “Running shoes” is present in its boosted title.</p><p><em>Weight:</em></p><p>Prioritizing Brands: We can set a higher weight for the brand property compared to description and price. Let’s say a weight of 2 for brand and a weight of 1 for the others. This tells the search algorithm that brand is a more important factor for ranking than descriptions or prices.</p><p>Example: Search Term: “Adidas shoes”</p><ul><li>Product A: Title: “Running Shoes”, Brand: “Adidas”, Description: “…” (High Weight for Brand)</li><li>Product B: Title: “Adidas Comfort Shoes”, Brand: “Unknown”, Description: “These are comfortable shoes…”</li></ul><p>Here, Product A might rank higher even though Product B has “Adidas” in its title (without boost). This is because the weight assigned to the brand property gives it more influence in the overall ranking.</p><p>If we introduce a boost for the title property in the scenario, the ranking dynamics between Product A and Product B would change.The outcome depends on the relative strength of the boost applied to the title and the weight assigned to the brand property.</p><p>1.4 <strong>analyzed=”{Boolean}true”:</strong></p><ul><li>The analyzed attribute <strong>controls how the property’s value is processed before being indexed</strong>. When set to true (like with the prop property in our example), Lucene performs text analysis on the property value. This analysis typically involves breaking text into individual terms, lowercase conversion, and potentially stemming (reducing words to their root form).</li><li>By enabling analysis, you ensure Lucene can effectively understand and match the content of the property during searches.</li></ul><p>1.5 <strong>isRegexp=”{Boolean}true”:</strong></p><ul><li>The isRegexp attribute applies to the prop property in our example and is set to true. This indicates that the name attribute (defined as ^[^\\/]*$) for the prop property specifies a regular expression.</li><li>Regular expressions are powerful tools for pattern matching in text. In this case, the provided regular expression ^[^\\/]*$ matches any string that doesn’t contain a forward slash character (/). This might be <strong>useful for indexing property names that follow a specific format or convention within our content</strong>.</li></ul><p>1.6 <strong>nodeScopeIndex=”{Boolean}true”:</strong></p><ul><li>The nodeScopeIndex attribute applies to the prop property and is set to true here. This setting instructs Lucene <strong>to index the ‘property’ value not only on the current node but also on all child nodes</strong> below it in the content hierarchy.</li><li>This can be beneficial if the property you’re indexing exists on multiple levels of your content structure and you want searches to find matches regardless of the node depth. To say, enabling nodeScopeIndex in AEM ensures that searches on pages (cq:Page nodes) return results even when the content is located within child nodes beneath the cq:Page node.</li></ul><p><strong>Example:</strong> With nodeScopeIndex enabled for the title property of a product page, searches will consider the title from both the page node and any child content nodes.</p><p>1.7 <strong>useInExcerpt=”{Boolean}true”:</strong></p><ul><li>The useInExcerpt attribute applies to the prop property and is set to true here. This setting allows Lucene to include the value of the prop property in search result excerpts.</li><li>Search results often display a short snippet of the content around the matched keywords. By enabling useInExcerpt, you’re making the prop <strong>property’s content eligible to be included in the excerpts</strong>, potentially improving the context and clarity of the search results.</li></ul><p><strong>2. Exclusion of Unnecessary Properties:</strong></p><p>Conversely, unnecessary properties are excluded from indexing. This approach streamlines the indexing process and prevents cluttering of the index with irrelevant data, leading to more efficient searches and avoiding false-positive matches.</p><p><strong>Sample Index Snippet:</strong></p><pre> ...<br>        excludedPaths=&quot;[/var,/etc/replication,/etc/workflow/instances,/jcr:system]&quot;<br>        includedPaths=&quot;[/content/kiran-sample]&quot;<br>        ..<br>        queryPaths=&quot;[/content/kiran-sample]&quot;<br>        type=&quot;lucene&quot;&gt;<br>        .....</pre><p>Let’s break down the properties in the above AEM index configuration:</p><p>2.1<strong>excludedPaths=”[/var,/etc/replication,/etc/workflow/instances,/jcr:system]”:</strong></p><p>This property specifies paths that are deliberately excluded from the indexing process. Here’s what’s excluded:</p><ul><li><strong>/var:</strong> This folder typically stores temporary data and configurations, which are not relevant for searching content.</li><li><strong>/etc/replication:</strong> This path likely contains replication-related configurations that don’t need to be searched.</li><li><strong>/etc/workflow/instances:</strong> This folder holds workflow instance data, not actual content for searching.</li><li><strong>/jcr:system:</strong> This is the root folder for the content repository system itself and shouldn’t be included in searches.</li></ul><p>2.2 <strong>includedPaths=”[/content/kiran-sample]”:</strong></p><p>This property defines the specific path that will be indexed. In this case, only the content located at /content/kiran-sample will be included in the index. This ensures the index focuses on the relevant content and avoids unnecessary data.</p><p>2.3 <strong>queryPaths=”[/content/kiran-sample]”:</strong></p><p>This property plays a crucial role in search queries. It specifies the paths that the search engine will consider when evaluating search queries. Even though it has the same value as includedPaths in this example, there’s a subtle difference:</p><ul><li>includedPaths determines what gets indexed.</li><li>queryPaths determines which paths are eligible to be matched during searches.</li></ul><p>In essence, searches will only find results within the path specified by queryPaths. So, if you have subfolders within /content/kiran-sample, queries will only find content within those subfolders if they are included in queryPaths.</p><p>Imagine you have a website with product information and blog posts:</p><ul><li><strong>includedPaths:</strong> Set to /content/website to index both product and blog post content.</li><li><strong>queryPaths:</strong> Set to /content/website/products only. This allows searches to find products, but excludes blog posts from search results even though they are indexed.</li></ul><p><strong>Why Use Different Values?</strong></p><p>Here are some reasons you might choose different values for includedPaths and queryPaths:</p><ul><li><strong>Restricting Search Scope:</strong> As in the example above, you might want to exclude certain types of content from search results even though they are indexed for potential future use.</li><li><strong>Security:</strong> You might index sensitive information but restrict search access to authorized users through queryPaths.</li><li><strong>Performance Optimization:</strong> For very large indexes, you could strategically use queryPaths to limit the search area, potentially improving search performance.</li></ul><p><strong>Optimizing our excludedPaths</strong></p><p>The provided sample excludes common system folders. Here’s an important point:</p><p>It’s generally more efficient to use includedPaths to specify the content you want to index. By default, system folders like /var and /etc are excluded. This approach ensures clarity and avoids the need to manage a potentially lengthy list of excluded paths, especially if your content structure is extensive.</p><p>However, excludedPaths can still be useful in specific scenarios. For instance, if you have a subpage under an includedPaths (like <strong>/content/kiran-sample/draft-pages</strong>) that you want to include in the index, you can leverage excludedPaths to achieve that granularity.</p><p><strong>3.Aggregates</strong></p><p>Aggregates consolidate content properties, enabling efficient retrieval of related information. By defining aggregates, AEM optimizes the organization of indexed data, enhancing the search experience for users.</p><p><strong>Sample Index Snippet:</strong></p><pre>&lt;aggregates jcr:primaryType=&quot;nt:unstructured&quot;&gt;<br>  &lt;nt:unstructured jcr:primaryType=&quot;nt:unstructured&quot;&gt;<br>    &lt;include0<br>        jcr:primaryType=&quot;nt:unstructured&quot;<br>        path=&quot;textPar&quot; /&gt;<br>    &lt;include1<br>        jcr:primaryType=&quot;nt:unstructured&quot;<br>        path=&quot;textPar/*&quot; /&gt;<br>    &lt;include2<br>        jcr:primaryType=&quot;nt:unstructured&quot;<br>        path=&quot;textPar/*/*&quot; /&gt;<br>    &lt;include3<br>        jcr:primaryType=&quot;nt:unstructured&quot;<br>        path=&quot;textPar/*/*/*&quot; /&gt;<br>    &lt;include4<br>        jcr:primaryType=&quot;nt:unstructured&quot;<br>        path=&quot;textPar/*/*/*/*&quot; /&gt;<br>  &lt;/nt:unstructured&gt;<br>&lt;/aggregates&gt;</pre><p><strong>Understanding Aggregation with textPar:</strong></p><p>In AEM indexes built upon Lucene, aggregation allows you to accumulate values from the textPar property and its child properties up to four levels deep for indexing purposes. This can be beneficial when our content has properties with hierarchical structures.</p><p>Here’s a breakdown of how the include elements work with textPar:</p><ul><li>include0 with path=”textPar”: This includes the direct values of the textPar property itself in the index.</li><li>include1 with path=”textPar/*”: This gathers the values of any child properties directly under textPar. For example, if textPar has child properties like heading and subheading, their values would be included.</li><li>include2 to include4 follow the same logic, progressively including the values of child properties within the previously included properties, reaching up to four levels deep from the initial textPar property.</li></ul><p><strong>Why Aggregate Properties?</strong></p><p>The reasons for configuring aggregation remain the same:</p><ul><li><strong>Improved Search Relevance:</strong> By including values from child properties, searches might have a better chance of finding relevant content, even if the search term directly matches a value within a nested property under textPar.</li><li><strong>Faceted Search Functionality:</strong> Aggregation can be useful for creating faceted navigation, where users can filter search results based on the values of these aggregated properties within the textPar hierarchy.</li></ul><p><strong>Important Considerations:</strong></p><ul><li>Extensive aggregation can increase the size of our index. Ensure you only aggregate properties that are truly valuable for searching to maintain optimal performance.</li><li>Define the appropriate depth of aggregation based on our content structure and search needs. Including values from very deep levels might not be necessary or beneficial.</li></ul><p><strong>4.Analyzers</strong></p><p>Analyzers process text before indexing, applying various transformations to improve search accuracy. AEM provides flexible options for configuring analyzers, allowing users to tailor the indexing process to their specific requirements.</p><p><strong>Sample Index Snippet:</strong></p><pre>&lt;analyzers jcr:primaryType=&quot;nt:unstructured&quot;&gt;<br>                &lt;default jcr:primaryType=&quot;nt:unstructured&quot;&gt;<br>                    &lt;charFilters jcr:primaryType=&quot;nt:unstructured&quot;&gt;<br>                        &lt;HTMLStrip jcr:primaryType=&quot;nt:unstructured&quot;/&gt;<br>                        &lt;Mapping jcr:primaryType=&quot;nt:unstructured&quot;/&gt;<br>                    &lt;/charFilters&gt;<br>                    &lt;tokenizer<br>                        jcr:primaryType=&quot;nt:unstructured&quot;<br>                        name=&quot;Standard&quot;/&gt;<br>                    &lt;filters jcr:primaryType=&quot;nt:unstructured&quot;&gt;<br>                        &lt;Synonym<br>                            jcr:primaryType=&quot;nt:unstructured&quot;<br>                            format=&quot;solr&quot;<br>                            ignoreCase=&quot;true&quot;<br>                            synonyms=&quot;synonyms.txt&quot;&gt;<br>                            &lt;synonyms.txt/&gt;<br>                        &lt;/Synonym&gt;<br>                        &lt;LowerCase jcr:primaryType=&quot;nt:unstructured&quot;/&gt;<br>                        &lt;Stop<br>                            jcr:primaryType=&quot;nt:unstructured&quot;<br>                            words=&quot;stop.txt&quot;&gt;<br>                            &lt;stop.txt/&gt;<br>                        &lt;/Stop&gt;<br>                        &lt;PorterStem jcr:primaryType=&quot;nt:unstructured&quot;/&gt;<br>                    &lt;/filters&gt;<br>                &lt;/default&gt;<br>            &lt;/analyzers&gt;<br></pre><p>this code snippet configures an analyzer that performs the following actions on text before it’s indexed:</p><ul><li>Removes HTML tags and potentially other markup (using HTMLStrip).</li><li>Performs character remapping if necessary (using Mapping).</li><li>Splits the text into individual terms (using StandardTokenizer).</li><li>Applies synonyms for improved search recall (using Filters).</li><li>Converts terms to lowercase for case-insensitive searching (using Filters).</li><li>Removes stopwords for efficiency (using Filters).</li><li>Applies stemming to potentially match different variations of the same word (using Filters).</li></ul><p>4.1 <strong>charFilters</strong>:</p><p>CharFilters preprocess text by removing or modifying specific characters. AEM supports the configuration of character filters to ensure that indexed content is clean and standardized, leading to more consistent search results.</p><p>Character filters are like text cleaners that modify text before it gets indexed. They can perform various actions, including:</p><ul><li><strong>Lowercasing:</strong> Converting all characters to lowercase (e.g., “Hello World” becomes “hello world”). This ensures case-insensitive searching, where searches for “HELLO” or “hello” would yield the same results.</li><li><strong>Accenting Handling:</strong> Converting accented characters to their base characters (e.g., “à” becomes “a”, “ä” becomes “a”). This improves search consistency by ensuring variations caused by accents don’t hinder results.</li><li><strong>Symbol Removal:</strong> Removing punctuation marks, special symbols, or other characters deemed irrelevant for searching (e.g., removing “&amp;” or “$” from text).</li></ul><p>4.2 <strong>Tokenizers</strong>:</p><p>Tokenizers break down text into individual terms or tokens, facilitating more granular search queries. AEM allows the configuration of tokenizers to suit the linguistic characteristics of the indexed content, leading to more accurate search results.</p><p><strong>Sample Index Snippet:</strong></p><pre>&lt;tokenizer<br>                        jcr:primaryType=&quot;nt:unstructured&quot;<br>                        name=&quot;Standard&quot;/&gt;</pre><p>Lucene offers various tokenizer implementations, each with different functionalities. The StandardTokenizer is a general-purpose tokenizer that performs the following actions on the input text:</p><ul><li><strong>Splits text at whitespace characters:</strong> This includes spaces, tabs, newlines, etc.</li><li><strong>Removes certain control characters:</strong> Characters deemed unsuitable for indexing are eliminated.</li></ul><p>It removes characters that wouldn’t be helpful for searching, like weird symbols or formatting marks.</p><p>Eg: Strange symbol &amp;%$# might disappear.</p><ul><li><strong>Handles alphabetic characters:</strong> Letters are separated into individual terms. It sees letters and separates them into individual terms, like building blocks for searching.</li></ul><p>Eg: “Hello World” becomes “Hello” “World” (separate words)</p><ul><li><strong>Handles alphanumeric strings:</strong> Words containing both letters and numbers are typically kept as single terms. However, you might need custom configurations depending on your specific needs.</li></ul><p>Eg: A product code like “Product101” stays together, but you might need special rules for some cases.</p><p>4.3 <strong>Analyzer Filters</strong>:</p><p>Filters are employed to refine search results based on specific criteria, such as metadata or content attributes. By adding filters, AEM enhances the precision of search queries and ensures that users find exactly what they are looking for.</p><p><strong>Sample Index Snippet:</strong></p><pre> &lt;filters jcr:primaryType=&quot;nt:unstructured&quot;&gt;<br>                        &lt;Synonym<br>                            jcr:primaryType=&quot;nt:unstructured&quot;<br>                            format=&quot;solr&quot;<br>                            ignoreCase=&quot;true&quot;<br>                            synonyms=&quot;synonyms.txt&quot;&gt;<br>                            &lt;synonyms.txt/&gt;<br>                        &lt;/Synonym&gt;<br>                        &lt;LowerCase jcr:primaryType=&quot;nt:unstructured&quot;/&gt;<br>                        &lt;Stop<br>                            jcr:primaryType=&quot;nt:unstructured&quot;<br>                            words=&quot;stop.txt&quot;&gt;<br>                            &lt;stop.txt/&gt;<br>                        &lt;/Stop&gt;<br>                        &lt;PorterStem jcr:primaryType=&quot;nt:unstructured&quot;/&gt;<br>                    &lt;/filters&gt;</pre><p><strong>In essence, this code snippet configures Lucene to:</strong></p><ul><li>Use synonyms to improve search recall by matching content that uses synonymous terms.</li><li>Exclude stopwords to reduce index size and improve search efficiency.</li><li>Convert terms to lowercase for case-insensitive searching.</li><li>Apply Porter stemming to potentially match different variations of the same word.</li></ul><p>We will see what Synonyms and Stop Words do in a while. Now, let’s first break down the <strong>LowerCase Filter &amp; Porter Stemmer</strong> then.</p><p><strong>4.3.1 LowerCase Filter:</strong></p><ul><li>The &lt;LowerCase&gt; element ensures all terms are converted to lowercase before further processing. This helps improve search matching as users might use different capitalization styles in their queries.</li></ul><p><strong>4.3.2 Porter Stemmer:</strong></p><ul><li>The &lt;PorterStem&gt; element applies the Porter Stemming algorithm. This algorithm reduces words to their root form (e.g., “running” becomes “run”). This can improve search recall by matching different variations of the same word.</li></ul><p><strong>Configuration of Synonyms and Stopwords</strong>:</p><p>AEM allows the configuration of synonyms and stopwords, which enriches the search experience by accounting for variations in language usage and excluding common, non-descriptive terms.</p><p>AEM indexes leverage Apache Lucene for searching, and Lucene offers functionalities to manage synonyms and stopwords during the indexing process. Here’s a breakdown of how you can configure them:</p><p><strong>4.3.3 Synonyms:</strong></p><p>Synonyms are words or phrases that have the same or similar meanings. By including synonyms in our index, you can improve search recall by allowing searches to match content that uses synonymous terms.</p><p>AEM doesn’t directly manage synonyms within the index configuration itself. Instead, it relies on an external synonym file. Here’s how to configure synonyms:</p><ul><li><strong>Create a Synonym File:</strong> Create a plain text file with the .txt extension. In each line of the file, specify synonyms separated by commas or whitespace.</li></ul><p>For example: car, automobile buy, purchase</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/0*h9FbhH5Izel0yZzO" /></figure><ul><li><strong>Reference the Synonym File in the Index:</strong> Within the &lt;analyzers&gt; section of our AEM index configuration, locate the &lt;default&gt; analyzer. Here, you’ll find a section named &lt;filters&gt;. Add a &lt;Synonym&gt; element with the following attributes:</li></ul><p>format=”solr” (specifies the synonym file format)</p><p>ignoreCase=”true” (optional, instructs Lucene to ignore case when applying synonyms)</p><p>synonyms=”[path/to/your/synonyms.txt]” (replace with the actual path to your synonym file)</p><p><strong>4.3.4 Stopwords:</strong></p><p>Stopwords are very common words (e.g., “the”, “a”, “an”) that are often excluded from searches as they don’t significantly contribute to the meaning of a query. Removing stopwords reduces the index size and can improve search efficiency.</p><p>Similar to synonyms, AEM relies on an external stopword file for configuration. Here’s how to manage stopwords:</p><ul><li><strong>Create a Stopword File:</strong> Create a plain text file with the .txt extension. List each stopword you want to exclude on a separate line.</li></ul><p>Eg:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*NwfDCiom6QDjSlen" /></figure><ul><li><strong>Reference the Stopword File in the Index:</strong> Within the &lt;analyzers&gt; section and &lt;default&gt; analyzer of your AEM index configuration, locate the &lt;filters&gt; section. Add a &lt;Stop&gt; element with the following attribute:</li><li>words=”[path/to/your/stopwords.txt]” (replace with the actual path to your stopword file)</li></ul><p><strong>Sample Index Snippet:</strong></p><pre>```<br>&lt;filters&gt;<br>    &lt;Stop jcr:primaryType=&quot;nt:unstructured&quot; words=&quot;stopwords.txt&quot;&gt;<br>        &lt;stopwords.txt/&gt;<br>    &lt;/Stop&gt;<br>&lt;/filters&gt;<br>```</pre><p><strong>Important Considerations:</strong></p><ul><li>By default, AEM doesn’t include pre-configured synonym or stopword files. You’ll need to create and manage these files yourself based on your specific requirements.</li><li>Choosing the right stopwords depends on your content type and search needs. You might need to experiment to find the optimal balance between efficiency and comprehensiveness.</li><li>Overuse of synonyms can lead to irrelevant matches in searches. Ensure your synonym list is relevant and well-maintained.</li></ul><p>Hopefully this article has equipped you with the knowledge to optimize your AEM index management and deliver a superior search experience for your users.</p><p><strong>Happy searching! And stay tuned for the next article on ”Craft Compelling Search Results: Highlighting Keywords &amp; Controlled Excerpts “.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8c66b59c1ef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/activate-aem/enhancing-aem-lucene-search-advanced-techniques-for-improved-search-functionality-part-2-d8c66b59c1ef">Enhancing AEM Lucene Search: Advanced Techniques for Improved Search Functionality : Part 2</a> was originally published in <a href="https://medium.com/activate-aem">Activate AEM</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>