本文整理汇总了Java中org.apache.solr.client.solrj.SolrQuery.ORDER.desc方法的典型用法代码示例。如果您正苦于以下问题:Java ORDER.desc方法的具体用法?Java ORDER.desc怎么用?Java ORDER.desc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.SolrQuery.ORDER
的用法示例。
在下文中一共展示了ORDER.desc方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attachSortClause
import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入方法依赖的package包/类
/**
* Sets up the sorting criteria. This will support sorting by multiple fields at a time
*
* @param query
* @param searchCriteria
*/
protected void attachSortClause(SolrQuery query, ProductSearchCriteria searchCriteria, String defaultSort) {
Map<String, String> solrFieldKeyMap = getSolrFieldKeyMap(searchCriteria);
String sortQuery = searchCriteria.getSortQuery();
if (StringUtils.isBlank(sortQuery)) {
sortQuery = defaultSort;
}
if (StringUtils.isNotBlank(sortQuery)) {
String[] sortFields = sortQuery.split(",");
for (String sortField : sortFields) {
String field = sortField.split(" ")[0];
if (solrFieldKeyMap.containsKey(field)) {
field = solrFieldKeyMap.get(field);
}
ORDER order = "desc".equals(sortField.split(" ")[1]) ? ORDER.desc : ORDER.asc;
if (field != null) {
query.addSortField(field, order);
}
}
}
}
示例2: attachSortClause
import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入方法依赖的package包/类
@Override
public void attachSortClause(SolrQuery query, SearchCriteria searchCriteria, String defaultSort, List<Field> fields) {
Map<String, String> solrFieldKeyMap = getSolrFieldKeyMap(searchCriteria, fields);
String sortQuery = searchCriteria.getSortQuery();
if (StringUtils.isBlank(sortQuery)) {
sortQuery = defaultSort;
}
if (StringUtils.isNotBlank(sortQuery)) {
String[] sortFields = sortQuery.split(",");
for (String sortField : sortFields) {
String field = sortField.split(" ")[0];
if (solrFieldKeyMap.containsKey(field)) {
field = solrFieldKeyMap.get(field);
}
ORDER order = "desc".equals(sortField.split(" ")[1]) ? ORDER.desc : ORDER.asc;
if (field != null) {
query.addSort(new SortClause(field, order));
}
}
}
}
示例3: applySortOptions
import org.apache.solr.client.solrj.SolrQuery.ORDER; //导入方法依赖的package包/类
public static SolrQuery applySortOptions(SolrQuery q, List<MCRSortBy> sortBy) {
for (MCRSortBy option : sortBy) {
SortClause sortClause = new SortClause(option.getFieldName(), option.getSortOrder() ? ORDER.asc
: ORDER.desc);
q.addSort(sortClause);
}
return q;
}