public static List<SolrQuery.SortClause> getSortClauses(String sortInfo) { List<SolrQuery.SortClause> sortClauses = new ArrayList<SolrQuery.SortClause>(); if (sortInfo == null) { sortClauses.add(SORT_CLAUSE); } else { for (String sortClauseData : sortInfo.split(SORT_FIELD_REQ_DELIM)) { if (nullOrEmpty(sortClauseData)) continue; Matcher m = SORT_PATTERN.matcher(sortClauseData); if (m.matches()) { sortClauses.add(new SolrQuery.SortClause(m.group(1), getSortOrder(m.group(2)))); } } } return sortClauses; }
public static List<String> getValidFieldNamesSubset(Collection<String> fieldNames) { List<String> fieldNamesSubset = new ArrayList<String>(); for (String fieldName : fieldNames) { if (!ignoreFieldName(fieldName, Arrays.asList(ID))) { fieldNamesSubset.add(fieldName); } } Collections.sort(fieldNamesSubset); return fieldNamesSubset; }
public static List<SolrQuery.SortClause> getSortClauses(String sortInfo, String sortOrder) { if (sortInfo == null) { return null; } if (sortOrder == null || sortInfo.contains(SORT_FIELD_REQ_DELIM)) { return getSortClauses(sortInfo); } List<SolrQuery.SortClause> sortClauses = new ArrayList<SolrQuery.SortClause>(); sortClauses.add(new SolrQuery.SortClause(sortInfo, sortOrder)); return sortClauses; }