08-23-2007 04:39 PM
<#– recent docs –>
<h2 style="margin-bottom:0.2em;">Most Recently Modified Docs</h2>
<table cellpadding=2>
<tr>
<td></td>
<td><b>Name</b></td>
<td><b>Location</b></td>
<td><b>Date</b></td>
</tr>
<#list space.childrenByXPath[".//*[subtypeOf('cm:content') and not(subtypeOf('fm:post'))]"]?sort_by(['properties','cm:modified'])?reverse as child>
<#if child_index = 15><#break></#if>
<tr>
<td><a href="/alfresco${child.url}" target="new"><img src="/alfresco${child.icon16}" border=0></a></td>
<td><a href="/alfresco${child.url}" target="new">${child.properties.name}</a></td>
<td><a href="/alfresco${child.parent.url}" target="new">${child.displayPath?replace(fullSpacePath,".")}</a></td>
<td>${child.properties["cm:modified"]?datetime}</td>
</tr>
</#list>
</table>
<#– Recent Topics/Posts –>
<#assign recentPosts=space.childrenByXPath[".//*[subtypeOf('fm:post')]"]?sort_by(['properties','cm:modified'])?reverse>
<#if (recentPosts?size > 0) >
<h2 style="margin-bottom:0.2em;">Most Recent Topics/Posts</h2>
<table cellpadding=2>
<tr>
<td></td>
<td><b>Topic/Post</b></td>
<td><b>Date/Author</b></td>
</tr>
<#list recentPosts as child>
<#if child_index = 8><#break></#if>
<tr>
<td valign="top"><a href="/alfresco${child.parent.url}"><img src="/alfresco${child.parent.icon16}" border=0></a></td>
<td valign="top"><a href="/alfresco${child.parent.url}">${child.parent.properties.name}</a><br/>
<#– <a href="/alfresco${child.url}" target="new">${child.properties.name}</a><br/> –>
<#if child.content?length < 40>
<a style="font-size:.9em;" href="/alfresco${child.url}" target="new">${child.content?replace("<br/>","- ")}</a><br/>
<#else>
<a style="font-size:.9em;" href="/alfresco${child.url}" target="new">${child.content?substring(0,40)?replace("<br/>","- ")}…</a><br/>
</#if>
</td>
<td valign="top">${child.properties["cm:modified"]?datetime}<br/>
<span style="font-size:.9em;">${child.properties["cm:modifier"]}</span>
</td>
</tr>
</#list>
</table>
</#if>
09-03-2007 07:07 AM
The problem seems to be that this performs terribly (when there's more than handful of docs). How can I make it perform much better?
AFAIK using lucene with search parameters is not an option in a template. So am I stuck having to do the sorting and limiting in template script?
When you do something like this, it's not pulling back the content in the search results that I am sorting, is it? Only meta-data right?
09-04-2007 05:42 PM
…
You can use a Lucene search to pull back docs rather than an XPath query - that is the performance issue.
You can use Lucene in a template, but you cannot use search parameters so the sorting will be done by FreeMarker - but that will unlikely be a perf issue once you remove the XPath!
…
Kevin
<#list space.childrenByXPath[".//*[subtypeOf('cm:content') and not(subtypeOf('fm:post'))]"]?sort_by(['properties','cm:modified'])?reverse as child> with<#list space.childrenByLuceneSearch["PATH:"${space.qnamePath}//*" AND TYPE:"cm:content" AND NOT TYPE:"fm:post""]?sort_by(['properties','cm:modified'])?reverse as child>09-04-2007 07:26 PM
well I have been converting my templates with Lucene instead of Xpath, but the performance is still unacceptable.
09-05-2007 05:16 AM
P.S. the naming of childrenByLuceneSearch is rather unfortunate.
I wish it really was the children of the current node instead of the whole repository.
09-06-2007 04:56 PM
….
You can optimize the query futher by removing the AND NOT clause and checking the type of each item in the freemarker template i.e. using an #IF to not render a row for items of fmost type.
…
Kevin
09-07-2007 06:25 AM
09-07-2007 08:31 AM
09-07-2007 05:09 PM
Indeed, see Date Range queries here:
http://wiki.alfresco.com/wiki/Search#Range_Queries
Kevin
<!– 1000*60*60*24*30 = 2592000000ms = 1 month –>
<#assign endDate=date?string("yyyy\\-MM\\-dd") + "T00:00:00"/>
<#assign startDate=incrementDate(date,-2592000000)?string("yyyy\\-MM\\-dd") + "T00:00:00"/>
<#list space.childrenByLuceneSearch["PATH:"${space.qnamePath}//*" AND TYPE:"cm:content" AND NOT TYPE:"fm:post" AND @cm\\:modified:[${startDate} TO ${endDate}]"]?sort_by(['properties','cm:modified'])?reverse as child>
09-10-2007 07:44 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.