List of usage examples for org.apache.lucene.search SortField rewrite
public SortField rewrite(IndexSearcher searcher) throws IOException
From source file:org.apache.solr.handler.component.ShardFieldSortedHitQueue.java
License:Apache License
Comparator<ShardDoc> getCachedComparator(SortField sortField, IndexSearcher searcher) { SortField.Type type = sortField.getType(); if (type == SortField.Type.SCORE) { return (o1, o2) -> { final float f1 = o1.score; final float f2 = o2.score; if (f1 < f2) return -1; if (f1 > f2) return 1; return 0; };//www . ja v a 2s.c o m } else if (type == SortField.Type.REWRITEABLE) { try { sortField = sortField.rewrite(searcher); } catch (IOException e) { throw new SolrException(SERVER_ERROR, "Exception rewriting sort field " + sortField, e); } } return comparatorFieldComparator(sortField); }
From source file:org.apache.solr.search.federated.ShardFieldSortedHitQueue.java
License:Apache License
Comparator<ShardDoc> getCachedComparator(SortField sortField, IndexSearcher searcher) { SortField.Type type = sortField.getType(); if (type == SortField.Type.SCORE) { return comparatorScore(); } else if (type == SortField.Type.REWRITEABLE) { try {/*from ww w .ja v a 2s.com*/ sortField = sortField.rewrite(searcher); } catch (IOException e) { throw new SolrException(SERVER_ERROR, "Exception rewriting sort field " + sortField, e); } } return comparatorFieldComparator(sortField); }