Skip to content

Commit

Permalink
Update documentation for new wildcards with the latest SewerRat API.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Nov 5, 2024
1 parent 2a8eb19 commit 9a97a63
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: SewerRat
Version: 0.2.12
Date: 2024-10-31
Version: 0.3.0
Date: 2024-11-05
Title: Client for the SewerRat API
Description:
Search metadata files across a shared filesystem via the SewerRat API.
Expand Down
13 changes: 7 additions & 6 deletions R/query.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@
#' If there are no parentheses, any \code{NOT} will take precedence over the other boolean operations,
#' i.e., the above query is the same as \code{NOT a b AND c d}.
#'
#' Even more advanced users can prefix any sequence of search terms with the name of a metadata field,
#' Users can prefix any sequence of search terms with the name of a metadata field,
#' to only search for matches within that field of the metadata file, e.g.,
#' \code{(title: prostate cancer) AND (genome: GRCh38 OR genome: GRCm38)}.
#' Note that this does not extend to the \code{AND}, \code{OR} and \code{NOT} keywords,
#' e.g., \code{title:foo OR bar} will not limit the search for \code{bar} to the \code{title} field.
#'
#' Extremely advanced users can attach a \code{\%} wildcard to any term to enable a partial search,
#' e.g., \code{neur\%} will match files with \code{neuron}, \code{neural}, \code{neurological}, etc.
#' Users can attach the usual \code{*} or \code{?} wildcards to any term to enable pattern matching.
#' For example, \code{neur*} will match files with \code{neuron}, \code{neural}, \code{neurological}, etc.,
#' while \code{cd?} will match files with \code{cd4}, \code{cd8}, \code{cd9}, etc.
#'
#' @author Aaron Lun
#' @examples
Expand All @@ -70,15 +71,15 @@
#' register(mydir, "metadata.json", url=info$url)
#'
#' query("aaron", url=info$url)
#' query("lun%", url=info$url)
#' query("lun% AND aaron", url=info$url)
#' query("lun*", url=info$url)
#' query("lun* AND aaron", url=info$url)
#' query("meal:bar%", url=info$url)
#'
#' query(path="diet/", url=info$url) # has 'diet/' in the path
#' query(user=Sys.info()["user"], url=info$url) # created by the current user
#' query(from=Sys.time() - 60, url=info$url) # no more than 1 minute old
#'
#' q <- query("lun%", url=info$url)
#' q <- query("lun*", url=info$url)
#' formatQueryResults(q)
#' @export
#' @import httr2
Expand Down
2 changes: 1 addition & 1 deletion R/startSewerRat.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' startSewerRat() # initialize a new instance.
#'
#' @export
startSewerRat <- function(db=tempfile(fileext=".sqlite3"), port=NULL, wait = 1, version = "1.0.13", overwrite = FALSE) {
startSewerRat <- function(db=tempfile(fileext=".sqlite3"), port=NULL, wait = 1, version = "1.1.0", overwrite = FALSE) {
if (!is.null(running$active)) {
return(list(new=FALSE, port=running$port, url=assemble_url(running$port)))
}
Expand Down
13 changes: 7 additions & 6 deletions man/query.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/startSewerRat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/testthat/test-query.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ write(file=file.path(mydir, "diet", "metadata.json"),
register(mydir, "metadata.json", url=info$url)

test_that("formatQueryResults works properly", {
q <- query("lun%", url=info$url)
q <- query("lun*", url=info$url)
res <- formatQueryResults(q)

expect_gt(nrow(res), 0L)
expect_gte(nrow(res), 2L)
expect_identical(nrow(res), length(q))
expect_equal(as.double(res$time), vapply(q, function(y) y$time, 0))
expect_identical(res$metadata[[1]], q[[1]]$metadata)
Expand Down
6 changes: 3 additions & 3 deletions vignettes/userguide.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ This function does not require filesystem access and can be executed remotely.

```{r}
lapply(query("foo", url=info$url), function(x) x$path)
lapply(query("bar%", url=info$url), function(x) x$path) # partial match to 'bar...'
lapply(query("bar% AND foo", url=info$url), function(x) x$path) # boolean operations
lapply(query("food:bar%", url=info$url), function(x) x$path) # match in the 'food' field
lapply(query("bar*", url=info$url), function(x) x$path) # partial match to 'bar...'
lapply(query("bar* AND foo", url=info$url), function(x) x$path) # boolean operations
lapply(query("food:bar*", url=info$url), function(x) x$path) # match in the 'food' field
```

We can also search on the user, path components, and time of creation:
Expand Down

0 comments on commit 9a97a63

Please sign in to comment.