mirror of https://github.com/apache/lucene.git
don't mix spaces and tabs (but use spaces only), no functional change
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150488 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a012f7cbfc
commit
ce2cd2f194
|
@ -100,105 +100,106 @@ import java.io.Serializable;
|
||||||
public class Sort
|
public class Sort
|
||||||
implements Serializable {
|
implements Serializable {
|
||||||
|
|
||||||
/** Represents sorting by computed relevance. Using this sort criteria
|
/**
|
||||||
* returns the same results as calling {@link Searcher#search(Query) Searcher#search()}
|
* Represents sorting by computed relevance. Using this sort criteria returns
|
||||||
* without a sort criteria, only with slightly more overhead. */
|
* 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();
|
public static final Sort RELEVANCE = new Sort();
|
||||||
|
|
||||||
/** Represents sorting by index order. */
|
/** Represents sorting by index order. */
|
||||||
public static final Sort INDEXORDER = new Sort (SortField.FIELD_DOC);
|
public static final Sort INDEXORDER = new Sort(SortField.FIELD_DOC);
|
||||||
|
|
||||||
// internal representation of the sort criteria
|
// internal representation of the sort criteria
|
||||||
SortField[] fields;
|
SortField[] fields;
|
||||||
|
|
||||||
|
/**
|
||||||
/** Sorts by computed relevance. This is the same sort criteria as
|
* Sorts by computed relevance. This is the same sort criteria as calling
|
||||||
* calling {@link Searcher#search(Query) Searcher#search()} without a sort criteria, only with
|
* {@link Searcher#search(Query) Searcher#search()}without a sort criteria,
|
||||||
* slightly more overhead. */
|
* only with slightly more overhead.
|
||||||
|
*/
|
||||||
public Sort() {
|
public Sort() {
|
||||||
this (new SortField[]{SortField.FIELD_SCORE, SortField.FIELD_DOC});
|
this(new SortField[] { SortField.FIELD_SCORE, SortField.FIELD_DOC });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Sorts by the terms in <code>field</code> then by index order (document
|
* Sorts by the terms in <code>field</code> then by index order (document
|
||||||
* number). The type of value in <code>field</code> is determined
|
* number). The type of value in <code>field</code> is determined
|
||||||
* automatically.
|
* automatically.
|
||||||
|
*
|
||||||
* @see SortField#AUTO
|
* @see SortField#AUTO
|
||||||
*/
|
*/
|
||||||
public Sort (String field) {
|
public Sort(String field) {
|
||||||
setSort (field, false);
|
setSort(field, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Sorts possibly in reverse by the terms in <code>field</code> then by
|
* Sorts possibly in reverse by the terms in <code>field</code> then by
|
||||||
* index order (document number). The type of value in <code>field</code> is determined
|
* index order (document number). The type of value in <code>field</code> is
|
||||||
* automatically.
|
* determined automatically.
|
||||||
|
*
|
||||||
* @see SortField#AUTO
|
* @see SortField#AUTO
|
||||||
*/
|
*/
|
||||||
public Sort (String field, boolean reverse) {
|
public Sort(String field, boolean reverse) {
|
||||||
setSort (field, reverse);
|
setSort(field, reverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Sorts in succession by the terms in each field.
|
* Sorts in succession by the terms in each field. The type of value in
|
||||||
* The type of value in <code>field</code> is determined
|
* <code>field</code> is determined automatically.
|
||||||
* automatically.
|
*
|
||||||
* @see SortField#AUTO
|
* @see SortField#AUTO
|
||||||
*/
|
*/
|
||||||
public Sort (String[] fields) {
|
public Sort(String[] fields) {
|
||||||
setSort (fields);
|
setSort(fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Sorts by the criteria in the given SortField. */
|
/** Sorts by the criteria in the given SortField. */
|
||||||
public Sort (SortField field) {
|
public Sort(SortField field) {
|
||||||
setSort (field);
|
setSort(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Sorts in succession by the criteria in each SortField. */
|
/** Sorts in succession by the criteria in each SortField. */
|
||||||
public Sort (SortField[] fields) {
|
public Sort(SortField[] fields) {
|
||||||
setSort (fields);
|
setSort(fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Sets the sort to the terms in <code>field</code> then by index order
|
* Sets the sort to the terms in <code>field</code> then by index order
|
||||||
* (document number). */
|
* (document number).
|
||||||
public final void setSort (String field) {
|
*/
|
||||||
setSort (field, false);
|
public final void setSort(String field) {
|
||||||
|
setSort(field, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Sets the sort to the terms in <code>field</code> possibly in reverse,
|
* Sets the sort to the terms in <code>field</code> possibly in reverse,
|
||||||
* then by index order (document number). */
|
* then by index order (document number).
|
||||||
public void setSort (String field, boolean reverse) {
|
*/
|
||||||
SortField[] nfields = new SortField[]{
|
public void setSort(String field, boolean reverse) {
|
||||||
new SortField (field, SortField.AUTO, reverse),
|
SortField[] nfields = new SortField[] {
|
||||||
SortField.FIELD_DOC
|
new SortField(field, SortField.AUTO, reverse), SortField.FIELD_DOC };
|
||||||
};
|
|
||||||
fields = nfields;
|
fields = nfields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Sets the sort to the terms in each field in succession. */
|
/** Sets the sort to the terms in each field in succession. */
|
||||||
public void setSort (String[] fieldnames) {
|
public void setSort(String[] fieldnames) {
|
||||||
final int n = fieldnames.length;
|
final int n = fieldnames.length;
|
||||||
SortField[] nfields = new SortField[n];
|
SortField[] nfields = new SortField[n];
|
||||||
for (int i = 0; i < n; ++i) {
|
for (int i = 0; i < n; ++i) {
|
||||||
nfields[i] = new SortField (fieldnames[i], SortField.AUTO);
|
nfields[i] = new SortField(fieldnames[i], SortField.AUTO);
|
||||||
}
|
}
|
||||||
fields = nfields;
|
fields = nfields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Sets the sort to the given criteria. */
|
/** Sets the sort to the given criteria. */
|
||||||
public void setSort (SortField field) {
|
public void setSort(SortField field) {
|
||||||
this.fields = new SortField[]{field};
|
this.fields = new SortField[] { field };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Sets the sort to the given criteria in succession. */
|
/** Sets the sort to the given criteria in succession. */
|
||||||
public void setSort (SortField[] fields) {
|
public void setSort(SortField[] fields) {
|
||||||
this.fields = fields;
|
this.fields = fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +208,7 @@ implements Serializable {
|
||||||
|
|
||||||
for (int i = 0; i < fields.length; i++) {
|
for (int i = 0; i < fields.length; i++) {
|
||||||
buffer.append(fields[i].toString());
|
buffer.append(fields[i].toString());
|
||||||
if ((i +1) < fields.length)
|
if ((i+1) < fields.length)
|
||||||
buffer.append(',');
|
buffer.append(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue