cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene query to find the 10 last modified nodes.

jacqueswvdh
Champ in-the-making
Champ in-the-making
Hi all,
I need to make a lucene query to find an list of nodes, ordered by modified  DESC. I only want the first 10 records back. I am using javascript.

This works:
   model.nodes = search.luceneSearch("@cm\\:modified:[2007-01-17T00:00:00 TO 2007-08-05T00:00:00]");

But I would like to do something like:
   model.nodes = search.luceneSearch("@cm\\:modified:[2007-01-17T00:00:00 TO 2007-08-05T00:00:00] AS mod ORDER BY mod DESC 10");

Thanks in advance for your help,
Jacques
2 REPLIES 2

dhalupa
Champ on-the-rise
Champ on-the-rise

jacqueswvdh
Champ in-the-making
Champ in-the-making
I found the answer. In the .ftl-file:
<#assign newsNodes = companyhome.childrenByLuceneSearch["TYPE:mn\\:newsItem"]?sort_by(["properties","modified"])?reverse >

I am now looking for a way to limit the resultset to the last 10 modified nodes
Of course, this can be done by:

   <#list newsNodes as newsNode>
      <#if newsNode_index < 10>

but I am sure it is more efficient to have lucen limit her output.