2 * Copyright 2004 The Apache Software Foundation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 namespace Lucene
.Net
.Search
21 /// <summary> Expert: Compares two ScoreDoc objects for sorting.
23 /// <p>Created: Feb 3, 2004 9:00:16 AM
26 /// <author> Tim Jones (Nacimiento Software)
28 /// <since> lucene 1.4
30 /// <version> $Id: ScoreDocComparator.cs,v 1.1 2005/01/17 19:54:30 joeshaw Exp $
32 public struct ScoreDocComparator_Fields
34 /// <summary>Special comparator for sorting hits according to computed relevance (document score). </summary>
35 public readonly static ScoreDocComparator RELEVANCE
;
36 /// <summary>Special comparator for sorting hits according to index order (document number). </summary>
37 public readonly static ScoreDocComparator INDEXORDER
;
38 static ScoreDocComparator_Fields()
40 RELEVANCE
= new AnonymousClassScoreDocComparator();
41 INDEXORDER
= new AnonymousClassScoreDocComparator1();
44 public class AnonymousClassScoreDocComparator
: ScoreDocComparator
46 public virtual int Compare(ScoreDoc i
, ScoreDoc j
)
48 if (i
.score
> j
.score
)
50 if (i
.score
< j
.score
)
54 public virtual System
.IComparable
SortValue(ScoreDoc i
)
56 return (float) i
.score
;
58 public virtual int SortType()
60 return SortField
.SCORE
;
63 public class AnonymousClassScoreDocComparator1
: ScoreDocComparator
65 public virtual int Compare(ScoreDoc i
, ScoreDoc j
)
73 public virtual System
.IComparable
SortValue(ScoreDoc i
)
75 return (System
.Int32
) i
.doc
;
77 public virtual int SortType()
82 public interface ScoreDocComparator
86 /// <summary> Compares two ScoreDoc objects and returns a result indicating their
89 /// <param name="i">First ScoreDoc
91 /// <param name="j">Second ScoreDoc
93 /// <returns> <code>-1</code> if <code>i</code> should come before <code>j</code><br><code>1</code> if <code>i</code> should come after <code>j</code><br><code>0</code> if they are equal
95 /// <seealso cref="java.util.Comparator">
97 int Compare(ScoreDoc i
, ScoreDoc j
);
100 /// <summary> Returns the value used to sort the given document. The
101 /// object returned must implement the java.io.Serializable
102 /// interface. This is used by multisearchers to determine how to collate results from their searchers.
104 /// <seealso cref="FieldDoc">
106 /// <param name="i">Document
108 /// <returns> Serializable object
110 System
.IComparable
SortValue(ScoreDoc i
);
113 /// <summary> Returns the type of sort. Should return <code>SortField.SCORE</code>, <code>SortField.DOC</code>, <code>SortField.STRING</code>, <code>SortField.INTEGER</code>,
114 /// <code>SortField.FLOAT</code> or <code>SortField.CUSTOM</code>. It is not valid to return <code>SortField.AUTO</code>.
115 /// This is used by multisearchers to determine how to collate results from their searchers.
117 /// <returns> One of the constants in SortField.
119 /// <seealso cref="SortField">