Skip to contents

Search for milestones matching a text pattern (regular expression) across specified fields in the milestone table.

Usage

search_milestones(
  pattern,
  fields = c("description", "tag", "note"),
  output = c("mid", "print", "data"),
  ignore.case = TRUE,
  ...
)

Arguments

pattern

Character string or regular expression to search for

fields

Character vector of field names to search. Default is c("description", "tag", "note"). Other searchable fields include: "slug", "date_from", "date_to", "location", "extra".

output

Output format: "mid" returns a numeric vector of milestone IDs, "print" prints formatted milestones and returns them invisibly, "data" returns the matching milestone data frame rows. Default is "mid".

ignore.case

Logical; if TRUE (default), case is ignored during matching

...

Additional arguments passed to print_milestone() when output = "print"

Value

Depends on output:

  • "mid": Numeric vector of matching milestone IDs

  • "print": Character vector of formatted milestones (invisibly), with formatted output printed to console

  • "data": Data frame of matching milestone rows

Details

The function searches for the pattern across all specified fields using regular expression matching. A milestone is included in the results if the pattern matches in ANY of the specified fields (OR logic).

The pattern argument accepts regular expressions, allowing for flexible searching:

  • Simple text: "contour" finds "contour map", "contours", etc.

  • Multiple terms: "chart|graph" finds either term

  • Word boundaries: "\\bmap\\b" finds "map" but not "bitmap"

  • Case patterns: "[Cc]artograph" finds "cartograph" or "Cartograph"

Examples

if (FALSE) { # \dontrun{
# Find milestones mentioning "statistical"
search_milestones("statistical")

# Search in specific fields
search_milestones("Halley", fields = c("description", "note"))

# Use regex to find chart OR graph
search_milestones("chart|graph", fields = "description")

# Get and print formatted results
search_milestones("contour", output = "print")

# Get full data frame of matches
results <- search_milestones("visualization", output = "data")

# Search tags for specific terms
search_milestones("^1st", fields = "tag")

# Case-sensitive search
search_milestones("Map", ignore.case = FALSE)
} # }