Filter Results

hal_filter(x, ...)

# S3 method for HALQuery
hal_filter(x, value, field = NULL, ...)

Arguments

x

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

...

Currently not used.

value

A character string specifying the value to be used to filter the results.

field

A character string specifying the field to filter along.

Value

An object of class HALQuery.

See also

Other query tools: hal_facet(), hal_group(), hal_query(), hal_select(), hal_sort()

Author

N. Frerebeau

Examples

library(magrittr)

## Simple filer
hal1 <- hal_api() %>% hal_filter("file", "submitType_s")
hal1$fq
#> [1] "submitType_s:file"

## Advanced filter
hal2 <- hal_api() %>% hal_filter(c("THESE", "HDR"), "docType_s")
hal2$fq
#> [1] "docType_s:(THESE OR HDR)"

## Multiple filters
hal3 <- hal_api() %>%
  hal_filter("[NOW-1MONTHS/DAY TO NOW/HOUR]", "submittedDate_tdate") %>%
  hal_filter("-notice", "submitType_s")
hal3$fq
#> [1] "submittedDate_tdate:[NOW-1MONTHS/DAY TO NOW/HOUR]"
#> [2] "submitType_s:-notice"                             

## Range filters
hal4 <- hal_api() %>% hal_filter("[2000 TO 2013]", "submittedDateY_i")
hal4$fq
#> [1] "submittedDateY_i:[2000 TO 2013]"

hal5 <- hal_api() %>% hal_filter("[Aa TO Ab]", "city_s")
hal5$fq
#> [1] "city_s:[Aa TO Ab]"