1 package org.apache.lucene.search;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * Expert: A ScoreDoc which also contains information about
22 * how to sort the referenced document. In addition to the
23 * document number and score, this object contains an array
24 * of values for the document from the field(s) used to sort.
25 * For example, if the sort criteria was to sort by fields
26 * "a", "b" then "c", the <code>fields</code> object array
27 * will have three elements, corresponding respectively to
28 * the term values for the document in fields "a", "b" and "c".
29 * The class of each element in the array will be either
30 * Integer, Float or String depending on the type of values
31 * in the terms of each field.
33 * <p>Created: Feb 11, 2004 1:23:38 PM
39 public class FieldDoc extends ScoreDoc {
41 /** Expert: The values which are used to sort the referenced document.
42 * The order of these will match the original sort criteria given by a
43 * Sort object. Each Object will have been returned from
44 * the <code>value</code> method corresponding
45 * FieldComparator used to sort this field.
47 * @see Searcher#search(Query,Filter,int,Sort)
49 public Object[] fields;
51 /** Expert: Creates one of these objects with empty sort information. */
52 public FieldDoc(int doc, float score) {
56 /** Expert: Creates one of these objects with the given sort information. */
57 public FieldDoc(int doc, float score, Object[] fields) {
62 /** Expert: Creates one of these objects with the given sort information. */
63 public FieldDoc(int doc, float score, Object[] fields, int shardIndex) {
64 super (doc, score, shardIndex);
68 // A convenience method for debugging.
70 public String toString() {
71 // super.toString returns the doc and score information, so just add the
73 StringBuilder sb = new StringBuilder(super.toString());
75 for (int i = 0; i < fields.length; i++) {
76 sb.append(fields[i]).append(", ");
78 sb.setLength(sb.length() - 2); // discard last ", "