|
What this is
Other links
The source codepackage org.apache.lucene.search; /** * Copyright 2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.Serializable; /** * Encapsulates sort criteria for returned hits. * *
Valid Types of Values* *There are three possible kinds of term values which may be put into * sorting fields: Integers, Floats, or Strings. Unless * {@link SortField SortField} objects are specified, the type of value * in the field is determined by parsing the first term in the field. * * Integer term values should contain only digits and an optional
* preceeding negative sign. Values must be base 10 and in the range
* Float term values should conform to values accepted by
* {@link Float Float.valueOf(String)} (except that String term values can contain any valid String, but should * not be tokenized. The values are sorted according to their * {@link Comparable natural order}. Note that using this type * of term value has higher memory requirements than the other * two types. * * Object Reuse* *One of these objects can be * used multiple times and the sort order changed between usages. * * This class is thread safe. * * Memory Usage* *Sorting uses of caches of term values maintained by the
* internal HitQueue(s). The cache is static and contains an integer
* or float array of length
For String fields, the cache is larger: in addition to the * above array, the value of every term in the field is kept in memory. * If there are many unique terms in the field, this could * be quite large. * * Note that the size of the cache is not affected by how many * fields are in the index and might be used to sort - only by * the ones actually used to sort a result set. * * The cache is cleared each time a new Created: Feb 12, 2004 10:53:57 AM
*
* @author Tim Jones (Nacimiento Software)
* @since lucene 1.4
* @version $Id: Sort.java,v 1.7 2004/04/05 17:23:38 ehatcher Exp $
*/
public class Sort
implements Serializable {
/** Represents sorting by computed relevance. Using this sort criteria
* returns the same results as calling {@link Searcher#search(Query) Searcher#search()}
* without a sort criteria, only with slightly more overhead. */
public static final Sort RELEVANCE = new Sort();
/** Represents sorting by index order. */
public static final Sort INDEXORDER = new Sort (SortField.FIELD_DOC);
// internal representation of the sort criteria
SortField[] fields;
/** Sorts by computed relevance. This is the same sort criteria as
* calling {@link Searcher#search(Query) Searcher#search()} without a sort criteria, only with
* slightly more overhead. */
public Sort() {
this (new SortField[]{SortField.FIELD_SCORE, SortField.FIELD_DOC});
}
/** Sorts by the terms in |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.