The <cm:search> tag searches for and retrieves content nodes based on a supplied query and stores the results in a variable.
<tagName attribute="value" />
query
Optional (String) - The search query to execute based on the query syntax described in Building Content Queries with Expressions. An expression is constructed with the query value. This is used if the expression attribute is not used.
expression
Optional (Expression) - The search expression to execute as a com.bea.p13n.expression.Expression. This value can be set programmatically.
id
Required (String) - The variable in which the search results are placed.
max
Optional (String) - The maximum number of content nodes returned by the search.
sortBy
Optional (String) - Use this attribute to sort the retrieved content in ascending or descending order. Enter the content attributes on which you want to sort the content.
However, you can sort content only on content properties that are explicit, meaning the values are stored in their own database column. System properties (see com.bea.content.expression.Search) are explicit by default. But the content properties you create in the WebLogic Administration portal (properties contained within the content "types" you create) are implicit. If you want to sort on those properties, you must make them explicit by doing the following:
Note: You can sort on explicit properties only against a BEA repository. Third-party repositories might behave differently.
Use ASC and DESC to sort retrieved content in ascending or descending order.
Examples:
sortBy=“myproducts ASC”
sortBy="cm_modifiedDate DESC" (This is a system attribute that is explicit by default.)
failOnError
Optional (boolean) - This attribute can have one of two values:
contextParams
Optional (Map) - The context parameters of the search.
useCache
Optional (boolean) - Set to true to cache the search results at the servlet container layer. (The default is "false.") A different cache is used than what is set in the Administration Portal. You do not need to set this cache attribute if you are already using application cache.
cacheScope
Optional (String) - The scope in which the cache is used: "application," "page," "request," or "session." The default is "session." See the description of the useCache attribute for guidance.
cacheId
Optional (String) - The variable in which the cached items are stored. See the description of the useCache attribute for guidance.
cacheTimeout
Optional (long) - The number of milliseconds to store
the items in cache. See the description of the useCache
attribute for guidance.
<cm:search id="docs" query="author = 'Hemingway'" /> <ul> <es:forEachInArray array="<%=docs%>" id="aDoc" type="com.bea.content.Node"> <li>The document title is: <cm:getProperty id="aDoc" name="Title" conversionType="html" /> </es:forEachInArray> </ul>