1

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.

4

1 回答 1

6

你快到了。可以按如下方式完成。

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

如果您需要检查子节点中的属性,您可以为 orderby 值提供相对路径。例如,如果您正在搜索 dam:Asset 并希望根据其元数据的 jcr:lastModified 属性对其进行排序,那么您的查询将与此类似。

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

如需进一步学习,请参阅

于 2014-02-10T12:50:20.173 回答