% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/analyze.R
\name{search_comments}
\alias{search_comments}
\title{Search Survey Comments}
\usage{
search_comments(survey, query, exact = FALSE, max_distance = 0.2)
}
\arguments{
\item{survey}{A glint_survey object or data frame containing survey data}

\item{query}{Character string to search for within comments}

\item{exact}{Logical. If \code{TRUE}, performs case-sensitive exact substring
matching. If \code{FALSE} (default), performs case-insensitive approximate
matching that also tolerates minor spelling differences.}

\item{max_distance}{Numeric between 0 and 1 controlling fuzzy match tolerance
when \code{exact = FALSE}. Higher values allow more differences (e.g. more
typos). Default is 0.2.}
}
\value{
A tibble with one row per matching comment containing:
\describe{
\item{question}{The survey question text}
\item{response}{The numeric survey response value}
\item{comment}{The comment text that matched the query}
\item{topics}{The comment topic(s) associated with the comment}
}
Returns an empty tibble with the same columns if no matches are found.
}
\description{
Searches through all survey comment text and returns matching responses
with their associated question text, numeric response values, comments, and
topics. Supports both exact substring matching and fuzzy (approximate)
matching that tolerates minor spelling differences.
}
\examples{
survey_path <- system.file("extdata", "survey_export.csv", package = "vivaglint")
survey <- read_glint_survey(survey_path, emp_id_col = "EMP ID")

# Fuzzy search (default) - finds "manager", "Manager", "managers", etc.
results <- search_comments(survey, "manager")

# Exact search - finds only the literal string "Manager" (case-sensitive)
results_exact <- search_comments(survey, "Manager", exact = TRUE)

# Wider fuzzy tolerance to catch more spelling variations
results_wide <- search_comments(survey, "management", max_distance = 0.3)
}
