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
| Parameter | Type | Description |
|---|---|---|
sortFields | List<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
| Parameter | Type | Description |
|---|---|---|
elem | SortField | The sort field to add. |
setSortFields
Sort setSortFields(List<SortField> sortFields)Specifies a list of fields based on which documents are to be sorted.
Parameters
| Parameter | Type | Description |
|---|---|---|
sortFields | List<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.
该文章对您有帮助吗?