private static DocComparatorSource GetComparatorSource(IBrowsable browser, SortField sf) { DocComparatorSource compSource = null; if (SortField.FIELD_DOC.Equals(sf)) { compSource = new DocComparatorSource.DocIdDocComparatorSource(); } else if (SortField.FIELD_SCORE.Equals(sf) || sf.Type == SortField.SCORE) { // we want to do reverse sorting regardless for relevance compSource = new ReverseDocComparatorSource(new DocComparatorSource.RelevanceDocComparatorSource()); } else if (sf is BoboCustomSortField) { BoboCustomSortField custField = (BoboCustomSortField)sf; DocComparatorSource src = custField.GetCustomComparatorSource(); Debug.Assert(src != null); compSource = src; } else { IEnumerable <string> facetNames = browser.FacetNames; string sortName = sf.Field; if (facetNames.Contains(sortName)) { var handler = browser.GetFacetHandler(sortName); Debug.Assert(handler != null); compSource = handler.GetDocComparatorSource(); } else { // default lucene field logger.Info("doing default lucene sort for: " + sf); compSource = GetNonFacetComparatorSource(sf); } } bool reverse = sf.Reverse; if (reverse) { compSource = new ReverseDocComparatorSource(compSource); } compSource.IsReverse = reverse; return(compSource); }
private static DocComparatorSource GetComparatorSource(IBrowsable browser, SortField sf) { DocComparatorSource compSource = null; if (SortField.FIELD_DOC.Equals(sf)) { compSource = new DocComparatorSource.DocIdDocComparatorSource(); } else if (SortField.FIELD_SCORE.Equals(sf) || sf.Type == SortField.SCORE) { // we want to do reverse sorting regardless for relevance compSource = new ReverseDocComparatorSource(new DocComparatorSource.RelevanceDocComparatorSource()); } else if (sf is BoboCustomSortField) { BoboCustomSortField custField = (BoboCustomSortField)sf; DocComparatorSource src = custField.GetCustomComparatorSource(); Debug.Assert(src != null); compSource = src; } else { IEnumerable<string> facetNames = browser.FacetNames; string sortName = sf.Field; if (facetNames.Contains(sortName)) { var handler = browser.GetFacetHandler(sortName); Debug.Assert(handler != null); compSource = handler.GetDocComparatorSource(); } else { // default lucene field logger.Info("doing default lucene sort for: " + sf); compSource = GetNonFacetComparatorSource(sf); } } bool reverse = sf.Reverse; if (reverse) { compSource = new ReverseDocComparatorSource(compSource); } compSource.IsReverse = reverse; return compSource; }