Created: Feb 11, 2004 1:25:29 PM @since lucene 1.4 @see Sort
140141142143144145146147148149150
public void testEagerOrdered() throws ParseException { populateCache(); // applying sort SortField sortField = new SortField("age", SortField.INT); Sort sort = new Sort(sortField); cacheQuery.sort(sort); ResultIterator iterator = cacheQuery.iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.EAGER)); try {
194195196197198199200201202203204
public void testList() throws ParseException { populateCache(); // applying sort SortField sortField = new SortField("age", SortField.INT); Sort sort = new Sort(sortField); cacheQuery.sort(sort); List<Object> results = cacheQuery.list(); assert results.size() == 4 : cacheQuery.getResultSize();
221222223224225226227228229230231
cacheQuery.firstResult(2); cacheQuery.maxResults(1); // applying sort SortField sortField = new SortField("age", SortField.INT); Sort sort = new Sort(sortField); cacheQuery.sort(sort); List<Object> results = cacheQuery.list(); assert results.size() == 1;
102103104105106107108109110111112
public void testLazyOrdered() throws ParseException { populateCache(); // applying sort SortField sortField = new SortField("age", SortField.INT); Sort sort = new Sort(sortField); cacheQuery.sort(sort); for (int i = 0; i < 2; i ++) { ResultIterator iterator = cacheQuery.iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.LAZY));
249250251252253254255256257258259
} public void testSetSort() throws ParseException { loadTestingData(); Sort sort = new Sort( new SortField("age", SortField.STRING)); queryParser = createQueryParser("name"); Query luceneQuery = queryParser.parse("Goat"); {
9293949596979899100101102
case DOUBLE: sortType = SortField.DOUBLE; break; } } sortField[i++] = new SortField(sc.getAttributePath(), sortType, !sc.isAscending()); } sort = new Sort(sortField); } QueryBuilder qb = searchManager.getSearchFactory().buildQueryBuilder().forEntity(parsingResult.getTargetEntity()).get();
116611671168116911701171117211731174117511761177117811791180
{ // order on jcr:score does not use the natural order as // implemented in lucene. score ascending in lucene means that // higher scores are first. JCR specs that lower score values // are first. sortFields.add(new SortField(null, SortField.SCORE, orderSpecs[i])); } else { path = npResolver.createJCRPath(orderProps[i]).getAsString(false); sortFields.add(new SortField(path, scs, !orderSpecs[i])); } } return sortFields.toArray(new SortField[sortFields.size()]); }
166116621663166416651666166716681669167016711672167316741675
145146147148149150151152153154155
case DOUBLE: sortType = SortField.DOUBLE; break; } } sortField[i++] = new SortField(sc.getAttributePath(), sortType, !sc.isAscending()); } cacheQuery = cacheQuery.sort(new Sort(sortField)); } int projSize = 0;
122123124125126127128129130131132