% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pmQueryBuild.R
\name{pmQueryBuild}
\alias{pmQueryBuild}
\title{Build a PubMed search query programmatically}
\usage{
pmQueryBuild(
  terms = NULL,
  fields = "Title/Abstract",
  language = NULL,
  pub_type = NULL,
  date_range = NULL,
  mesh_terms = NULL,
  author = NULL,
  journal = NULL,
  operator = "AND"
)
}
\arguments{
\item{terms}{is a character or character vector. Search terms to look for in title and abstract fields.}

\item{fields}{is a character or character vector. PubMed search tags to apply.
Default is \code{c("Title/Abstract")}. Common fields include: "Title/Abstract", "Title", "Author",
"MeSH Terms", "Affiliation", "Journal".}

\item{language}{is a character or NULL. Language filter (e.g. "english", "french"). Default is \code{NULL} (no filter).}

\item{pub_type}{is a character or NULL. Publication type filter (e.g. "Journal Article", "Review", "Clinical Trial").
Default is \code{NULL} (no filter).}

\item{date_range}{is a character vector of length 2 or NULL. Date range in format \code{c("YYYY", "YYYY")} or
\code{c("YYYY/MM/DD", "YYYY/MM/DD")}. Default is \code{NULL} (no filter).}

\item{mesh_terms}{is a character or character vector or NULL. MeSH (Medical Subject Headings) terms.
Default is \code{NULL} (no filter).}

\item{author}{is a character or character vector or NULL. Author names. Default is \code{NULL}.}

\item{journal}{is a character or character vector or NULL. Journal names or abbreviations. Default is \code{NULL}.}

\item{operator}{is a character. Boolean operator to combine multiple \code{terms}. One of "AND", "OR".
Default is \code{"AND"}.}
}
\value{
a character string containing the formatted PubMed query.
}
\description{
It helps to build a valid PubMed search query using the Entrez query language,
combining multiple search terms with Boolean operators.
}
\details{
The function constructs a query string compatible with NCBI's Entrez search system.
Multiple terms within the same parameter are combined with the specified \code{operator},
while different parameters (terms, language, pub_type, etc.) are combined with AND.

For more information about PubMed search tags, visit:
\href{https://pubmed.ncbi.nlm.nih.gov/help/#search-tags}{https://pubmed.ncbi.nlm.nih.gov/help/#search-tags}
}
\examples{

# Simple query
q <- pmQueryBuild(terms = "bibliometrics", language = "english",
                  pub_type = "Journal Article", date_range = c("2000", "2023"))

# Multiple terms
q <- pmQueryBuild(terms = c("machine learning", "deep learning"),
                  operator = "OR", language = "english")

# MeSH terms query
q <- pmQueryBuild(mesh_terms = "COVID-19", pub_type = "Review",
                  date_range = c("2020", "2024"))

# Author search
q <- pmQueryBuild(terms = "bibliometrics", author = "Aria M")

}
\seealso{
\code{\link{pmQueryTotalCount}}

\code{\link{pmApiRequest}}
}
