Skip to contents

Sort Results

Usage

hal_sort(query, field, decreasing = FALSE, ...)

hal_sort(query, field, decreasing = FALSE, ...)

Arguments

query

An object of class HALQuery (typically returned by hal_query()).

field

A character string specifying the field to be used to sort the results.

decreasing

A logical scalar: should the sort be increasing or decreasing?

...

Currently not used.

Value

An object of class HALQuery.

See also

Other query tools: hal_facet(), hal_filter(), hal_group(), hal_query(), hal_select(), operators

Author

N. Frerebeau

Examples

## Select fields
(q <- hal_query() |> hal_sort("docid"))
#> $q
#> [1] "text:*"
#> 
#> $fl
#> [1] "docid,label_s"
#> 
#> $wt
#> [1] "json"
#> 
#> $sort
#> [1] "docid asc"
#> 
#> attr(,"class")
#> [1] "HALQuery"

## Update query
hal_sort(q, "producedDate_tdate", decreasing = TRUE)
#> $q
#> [1] "text:*"
#> 
#> $fl
#> [1] "docid,label_s"
#> 
#> $wt
#> [1] "json"
#> 
#> $sort
#> [1] "producedDate_tdate desc"
#> 
#> attr(,"class")
#> [1] "HALQuery"