2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 namespace Mono.Lucene.Net.Search
23 /// <summary> Expert: Compares two ScoreDoc objects for sorting.
25 /// <p/>Created: Feb 3, 2004 9:00:16 AM
28 /// <since> lucene 1.4
30 /// <version> $Id: ScoreDocComparator.java 738219 2009-01-27 20:15:21Z mikemccand $
32 /// <deprecated> use {@link FieldComparator}
34 [Obsolete("use FieldComparator")]
35 public struct ScoreDocComparator_Fields{
36 /// <summary>Special comparator for sorting hits according to computed relevance (document score). </summary>
37 public readonly static ScoreDocComparator RELEVANCE;
38 /// <summary>Special comparator for sorting hits according to index order (document number). </summary>
39 public readonly static ScoreDocComparator INDEXORDER;
40 static ScoreDocComparator_Fields()
42 RELEVANCE = new AnonymousClassScoreDocComparator();
43 INDEXORDER = new AnonymousClassScoreDocComparator1();
46 class AnonymousClassScoreDocComparator : ScoreDocComparator
48 public virtual int Compare(ScoreDoc i, ScoreDoc j)
50 if (i.score > j.score)
52 if (i.score < j.score)
56 public virtual System.IComparable SortValue(ScoreDoc i)
58 return (float) i.score;
60 public virtual int SortType()
62 return SortField.SCORE;
65 class AnonymousClassScoreDocComparator1 : ScoreDocComparator
67 public virtual int Compare(ScoreDoc i, ScoreDoc j)
75 public virtual System.IComparable SortValue(ScoreDoc i)
77 return (System.Int32) i.doc;
79 public virtual int SortType()
84 public interface ScoreDocComparator
87 /// <summary> Compares two ScoreDoc objects and returns a result indicating their
90 /// <param name="i">First ScoreDoc
92 /// <param name="j">Second ScoreDoc
94 /// <returns> a negative integer if <code>i</code> should come before <code>j</code><br/>
95 /// a positive integer if <code>i</code> should come after <code>j</code><br/>
96 /// <code>0</code> if they are equal
98 /// <seealso cref="java.util.Comparator">
100 int Compare(ScoreDoc i, ScoreDoc j);
102 /// <summary> Returns the value used to sort the given document. The
103 /// object returned must implement the java.io.Serializable
104 /// interface. This is used by multisearchers to determine how
105 /// to collate results from their searchers.
107 /// <seealso cref="FieldDoc">
109 /// <param name="i">Document
111 /// <returns> Serializable object
113 System.IComparable SortValue(ScoreDoc i);
115 /// <summary> Returns the type of sort. Should return <code>SortField.SCORE</code>,
116 /// <code>SortField.DOC</code>, <code>SortField.STRING</code>,
117 /// <code>SortField.INTEGER</code>, <code>SortField.FLOAT</code> or
118 /// <code>SortField.CUSTOM</code>. It is not valid to return
119 /// <code>SortField.AUTO</code>.
120 /// This is used by multisearchers to determine how to collate results
121 /// from their searchers.
123 /// <returns> One of the constants in SortField.
125 /// <seealso cref="SortField">