Extending Assets Search

You can extend Adobe Experience Manager (AEM) Assets search capabilities. Out of the box, AEM Assets searches for assets by strings.

Searching is done via the QueryBuilder interface so the search can be customized with several predicates. You can overlay the default set of predicates in the following directory: /apps/dam/content/search/searchpanel/facets.

Overlaying

To overlay the preconfigured predicates, copy the facets node from /libs/dam/content/search/searchpanel to /apps/dam/content/search/searchpanel/ or specify another facetURL property in the searchpanel configuration (the default is to /libs/dam/content/search/searchpanel/facets.overlay.infinity.json).

Note:

By default, the directory structure under /apps does not exist and needs to be created. Ensure that the node types match those under /libs.

Adding tabs

You can add additional Search tabs by configuring them in the AEM Assets Admin. To create additional tabs:

Create the folder structure /apps/wcm/core/content/damadmin/tabs, if it does not already exist, and copy the tabs node from /libs/wcm/core/content/damadmin and paste it.

Create and configure the second tab, as desired.

Note:

When you create a second siteadminsearchpanel, be sure to set an id property in order to prevent form conflicts.

<%--
Sample title predicate component
--%><%@ page import="java.util.Calendar" %><%
%><%@include file="/libs/foundation/global.jsp"%><%
// A unique id is necessary in case this predicate is inserted multiple times on the same page
String elemId = "cq-predicate-" + Long.toString(Calendar.getInstance().getTimeInMillis());
%><div class="predicatebox">
<div class="title">Title</div>
<%-- The wrapper for the form elements. All items will be append to this wrapper. --%>
<div id="<%= elemId %>" class="content"></div>
</div><script type="text/javascript">
CQ.Ext.onLoad(function() {
var predicateName = "property";
var propertyName = "jcr:content/metadata/dc:title";
var elemId = "<%= elemId %>";
// Get the page wide available QueryBuilder.
var qb = CQ.search.Util.getQueryBuilder();
// createId adds a counter to the predicate name - useful in case this predicate
// is inserted multiple times on the same page.
var id = qb.createId(predicateName);
// Hidden field that defines the property to search for; in our case this
// is the "dc:title" metadata. The name "property" (or "1_property", "2_property" etc.)
// indicates the server to use the property predicate
// (com.day.cq.search.eval.JcrPropertyPredicateEvaluator).
qb.addField({
"xtype": "hidden",
"renderTo": elemId,
"name": id,
"value": propertyName
});
// The visible text field. The name has to be like the one of the hidden field above
// plus the ".value" suffix.
qb.addField({
"xtype": "textfield",
"renderTo": elemId,
"name": id + ".value"
});
// Depending on the predicate additional parameters allow to configure the
// predicate. Here we add an operation parameter to create a "like" query.
// Again note the name set to the id and a suffix.
qb.addField({
"xtype": "hidden",
"renderTo": elemId,
"name": id + ".operation",
"value": "like"
});
});
</script>

To make the component available, you need to be able to edit it. To make a component editable, in CRXDE, add a node cq:editConfig of primary type cq:EditConfig. So that you can remove paragraphs, add a multi-value property cq:actions with a single value of DELETE.

Navigate to your browser, and on your sample page (for example, press.html) switch to design mode and enable your new component for the predicate paragraph system (for example, left).

In Edit mode, the new component is now available in the sidekick (found in the Search group). Insert the component in the Predicates column and type a search word, for example, Diamond and click the magnifying glass to start the search.

Note:

When searching, be sure to type in the term exactly, including the correct case.

To make the component available, you need to be able to edit it. To make a component editable, in CRXDE, add a node cq:editConfig of primary type cq:EditConfig. So that you can remove paragraphs, add a multi-value property cq:actions with a single value of DELETE.

Navigate to your browser, and on your sample page (for example, press.html) switch to design mode and enable your new component for the predicate paragraph system (for example, left).

In Edit mode, the new component is now available in the sidekick (found in the Search group). Insert the component in the Predicates column.

Installed Predicate Widgets

The following predicates are available as preconfigured ExtJS widgets.

FulltextPredicate

Property

Type

Description

predicateName

String

Name of the predicate. Defaults to 'fulltext'

searchCallback

Function

Callback for triggering search on event 'keyup'. Default to 'CQ.wcm.SiteAdmin.doSearch'

Customizing Search Results

The presentation of search results on an Asset Share page is governed by the selected lens. AEM Assets comes with a set of predefined lenses that can be used to customize an Asset Share page. Customizing an Asset Share in this way is covered in Creating and Configuring an Asset Share Page.

In addition to using pre-existing lenses, AEM developers can also create their own lenses.

Twitter™ and Facebook posts are not covered under the terms of Creative Commons.