Sort class

更新时间:
复制 MD 格式

The Sort class configures the sort fields for a search query.

Constructors

Sort(List\<SortField\> sortFields)

Creates a Sort object with a predefined list of sort fields.

Parameters

ParameterTypeDescription
sortFieldsList<SortField>The sort fields to apply, in priority order.

Sort()

Creates a Sort object with no sort fields. Add fields later using addToSortFields or setSortFields.

Methods

addToSortFields

void addToSortFields(SortField elem)

Adds a sort field to the existing list.

Parameters

ParameterTypeDescription
elemSortFieldThe sort field to add.

setSortFields

Sort setSortFields(List<SortField> sortFields)

Specifies a list of fields based on which documents are to be sorted.

Parameters

ParameterTypeDescription
sortFieldsList<SortField>The new list of sort fields, in priority order.

Return value

The current Sort object (Sort).

getSortFields

List<SortField> getSortFields()

Returns the current list of sort fields.

Return value

The list of sort fields (List<SortField>).

getSortFieldsSize

int getSortFieldsSize()

Returns the number of sort fields in the current list.

Return value

The number of sort fields (int).

What's next

  • SortField: For more information, see the "SortField" topic.