Question

basically below is the java coding part, which the result will then be populated to a .csv file. However, I dont seem get the ordering part right (last line in below snippet).

Map<String, String> map = new HashMap<String, String>();
map.put("path", "/etc/crx-db/form-data/career");
map.put("type", "nt:unstructured");
map.put("p.limit", "-1");
map.put("daterange.property", "created");
map.put("daterange.lowerBound", from);
map.put("daterange.lowerOperation", ">=");
map.put("daterange.upperOperation", "<=");
map.put("daterange.upperBound", to);
map.put("orderby", "created"); //<--here

Providing that in crx repositry (/etc/crx-db/form-data/career), I have nodes: data1, data2, data3... Then for each node, there is one property - Name: created | Type: Date | Value: 2014-01-28T23:21:15.029+08:00 (eg) However my result in .csv is incorrect like (row 1 to 5):

  • 2014-01-28T23:21:15.029+08:00
  • 2014-01-28T23:48:12.219+08:00
  • 2014-02-10T18:44:38.914+08:00 <-- unsorted
  • 2014-02-10T18:43:32.426+08:00 <-- unsorted
  • 2014-02-10T18:46:53.319+08:00

Pretty sure my code wasn't running. Any idea on how can I tweak my java code to make the sorting happen? As in returning sorted data1, data2, data3... based on the property created. Thanks.

Was it helpful?

Solution

You were almost there. It can be done as follows.

map.put("orderby", "@created"); 
map.put("orderby.sort", "desc"); // in case you want it descending

In case you need to check property within a child node, you can provide the relative path to that for the orderby value. For eg., if you are searching for dam:Asset and want to order them based on the jcr:lastModified property of its metadata, then your query would be something similar to this.

map.put("path", "/content/dam/geometrixx");
map.put("type", "dam:Asset");
map.put("orderby","@jcr:content/metadata/jcr:lastModified");

For further learning refer this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top