Peržiūrite versijai skirtą žinyno turinį:
- 6.5
- 6.4
- 6.3
- 6.2
- Ankstesnės versijos
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.
You can also add additional tabs to the AEM Assets admin panel.
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).

Pastaba:
By default, the directory structure under /apps does not exist and needs to be created. Ensure that the node types match those under /libs.
You can add additional Search tabs by configuring them in the AEM Assets Admin. To create additional tabs:
AEM Assets comes with a set of predefined predicates 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 predicates, AEM developers can also create their own predicates using the Query Builder API.
Creating custom predicates requires basic knowledge about the Widgets framework.
The best practice is to copy an existing predicate and adjust it. Sample predicates are located in /libs/cq/search/components/predicates.
-
<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Component" jcr:title="Title Predicate" sling:resourceSuperType="foundation/components/parbase" allowedParents="[*/parsys]" componentGroup="Search"/>
-
<%-- 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>
-
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.
Pastaba:
When searching, be sure to type in the term exactly, including the correct case.
-
<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Component" jcr:title="Image Formats" sling:resourceSuperType="foundation/components/parbase" allowedParents="[*/parsys]" componentGroup="Search"/>
-
<%-- Sample group 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">Image Formats</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:format"; var elemId = "<%= elemId %>"; // Get the page wide available QueryBuilder. var qb = CQ.search.Util.getQueryBuilder(); // Create a unique group ID; will return e.g. "1_group". var groupId = qb.createGroupId(); // Hidden field that defines the property to search for - in our case "dc:format" - // and declares the group of predicates. "property" in the name ("1_group.property") // indicates to the server to use the "property predicate" // (com.day.cq.search.eval.JcrPropertyPredicateEvaluator). qb.addField({ "xtype": "hidden", "renderTo": "<%= elemId %>", "name": groupId + "." + predicateName, // 1_group.property "value": propertyName }); // Declare to combine the multiple values using OR. qb.add(new CQ.Ext.form.Hidden({ "name": groupId + ".p.or", // 1_group.p.or "value": "true" })); // The options var options = [ { "label":"JPEG", "value":"image/jpeg"}, { "label":"PNG", "value":"image/png" }, { "label":"GIF", "value":"image/gif" } ]; // Build a checkbox for each option. for (var i = 0; i < options.length; i++) { qb.addField({ "xtype": "checkbox", "renderTo": "<%= elemId %>", // 1_group.property.0_value, 1_group.property.1_value etc. "name": groupId + "." + predicateName + "." + i + "_value", "inputValue": options[i].value, "boxLabel": options[i].label, "listeners": { "check": function() { // Submit the search form when checking/unchecking a checkbox. qb.submit(); } } }); } });
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' |
Property |
Type | Description |
predicateName | String | Name of the predicate. Defaults to 'property' |
propertyName | String | Name of the JCR property. Default to 'jcr:title' |
defaultValue |
String |
Prefilled default value. |
Property |
Type | Description |
predicateName | String | Name of the predicate. Defaults to 'path' |
rootPath | String | Root path of the predicate. Default to '/content/dam' |
pathFieldPredicateName | String | Default to 'folder' |
showFlatOption | Boolean | Flag to show Checkbox 'search in subfolders'. Defaults to true. |
Property |
Type | Description |
predicateName | String | Name of the predicate. Defaults to 'daterange' |
propertyname | String | Name of the JCR property. Default to 'jcr:content/jcr:lastModified' |
defaultValue | String | Prefilled default value |
Property |
Type | Description |
title | String | Adds an additional top title |
predicateName | String | Name of the predicate. Defaults to 'daterange' |
propertyname | String | Name of the JCR property. Default to 'jcr:content/metadata/cq:tags' |
collapse | String | Collapse level. Defaults to 'level1' |
triggerSearch | Boolean | Flag for triggering search on check. Defaults to false |
searchCallback | Function | Callback for triggering search. Defaults to 'CQ.wcm.SiteAdmin.doSearch' |
searchTimeoutTime | Number | Timeout before searchCallback is fired. Defaults to 800ms |
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.