public static SortCollector BuildSortCollector(IBrowsable browser, Query q, SortField[] sort, int offset, int count, bool forceScoring, bool fetchStoredFields, IEnumerable <string> termVectorsToFetch, string[] groupBy, int maxPerGroup, bool collectDocIdCache) { bool doScoring = forceScoring; if (sort == null || sort.Length == 0) { if (q != null && !(q is MatchAllDocsQuery)) { sort = new SortField[] { SortField.FIELD_SCORE }; } } if (sort == null || sort.Length == 0) { sort = new SortField[] { SortField.FIELD_DOC }; } IEnumerable <string> facetNames = browser.FacetNames; foreach (SortField sf in sort) { if (sf.Type == SortField.SCORE) { doScoring = true; break; } } DocComparatorSource compSource; if (sort.Length == 1) { SortField sf = Convert(browser, sort[0]); compSource = GetComparatorSource(browser, sf); } else { DocComparatorSource[] compSources = new DocComparatorSource[sort.Length]; for (int i = 0; i < sort.Length; ++i) { compSources[i] = GetComparatorSource(browser, Convert(browser, sort[i])); } compSource = new MultiDocIdComparatorSource(compSources); } return(new SortCollectorImpl(compSource, sort, browser, offset, count, doScoring, fetchStoredFields, termVectorsToFetch, groupBy, maxPerGroup, collectDocIdCache)); }
public static SortCollector BuildSortCollector(IBrowsable browser, Query q, SortField[] sort, int offset, int count, bool forceScoring, bool fetchStoredFields, IEnumerable<string> termVectorsToFetch, string[] groupBy, int maxPerGroup, bool collectDocIdCache) { bool doScoring = forceScoring; if (sort == null || sort.Length == 0) { if (q != null && !(q is MatchAllDocsQuery)) { sort = new SortField[] { SortField.FIELD_SCORE }; } } if (sort == null || sort.Length == 0) { sort = new SortField[] { SortField.FIELD_DOC }; } IEnumerable<string> facetNames = browser.FacetNames; foreach (SortField sf in sort) { if (sf.Type == SortField.SCORE) { doScoring = true; break; } } DocComparatorSource compSource; if (sort.Length == 1) { SortField sf = Convert(browser, sort[0]); compSource = GetComparatorSource(browser, sf); } else { DocComparatorSource[] compSources = new DocComparatorSource[sort.Length]; for (int i = 0; i < sort.Length; ++i) { compSources[i] = GetComparatorSource(browser, Convert(browser, sort[i])); } compSource = new MultiDocIdComparatorSource(compSources); } return new SortCollectorImpl(compSource, sort, browser, offset, count, doScoring, fetchStoredFields, termVectorsToFetch, groupBy, maxPerGroup, collectDocIdCache); }