q parameter is the heart of every Custom Search API request. Everything you type into it — individual keywords, quoted phrases, boolean logic, and wildcards — directly shapes which pages Google considers and which it discards. This page covers every syntax feature available in q, plus the three companion API parameters (exactTerms, excludeTerms, orTerms) that give you additional programmatic control over inclusion and exclusion.
Basic keyword queries
By default, Google treats multiple keywords as an implicitAND: every term must appear somewhere in the document for it to qualify as a result. Keyword order does not matter, but all terms must be present.
Phrase search with quotation marks
Wrap terms in double quotes to require an exact phrase — the words must appear adjacent and in the specified order."climate change adaptation" vs. climate change adaptation (which would also match pages about climate adaptation that don’t mention change).
Boolean operators
- AND (implicit)
- OR
- NOT / minus (-)
AND is the default — you don’t need to write it. Separate keywords with spaces and Google requires all of them.Grouping with parentheses
Use parentheses to control the logical evaluation order when you mixOR with other terms, just as you would in a mathematical expression.
Parentheses are a hint to Google’s query parser but not universally enforced in all scenarios. For strict inclusion/exclusion logic, combine parentheses with the
exactTerms, excludeTerms, and orTerms API parameters described below.Wildcard (*)
The asterisk (*) acts as a wildcard that matches any word or sequence of words within a phrase. It is most useful inside quoted phrases to fill in an unknown word.
The wildcard works within quoted phrases. Outside quotes,
* has no special behavior and is treated as a regular character or ignored. Use it when you want to find a well-known phrase but are unsure of one word.API parameters for programmatic filtering
In addition to inline syntax inq, the API exposes three dedicated parameters that give you clean, programmatic control over term inclusion and exclusion — useful when your query strings are generated dynamically.
- exactTerms
- excludeTerms
- orTerms
exactTerms — Requires every result to contain a specific phrase. This is the API-parameter equivalent of adding a quoted phrase to q, but it is applied as an additional mandatory constraint on top of whatever is already in q.string
A phrase that must appear verbatim in every returned document. Only one phrase is supported per request.
exactTerms when your application generates queries programmatically and you want to guarantee that a specific phrase appears in every result without embedding it directly in the q string.Combining q syntax with API parameters
You can layer all three API parameters on top of q in the same request. Google applies them additionally — q is evaluated first, then exactTerms adds a required phrase, excludeTerms strips unwanted documents, and orTerms adds an OR constraint.
- Must contain the phrase “cost reduction” (
exactTerms) - Must not mention “nuclear” (
excludeTerms) - Must mention at least one of “investment”, “funding”, or “grant” (
orTerms)
Quick-reference syntax table
Practical examples
Competitive research: find mentions of a topic that exclude your own domain
Competitive research: find mentions of a topic that exclude your own domain
News monitoring: find recent articles on a topic with specific framing
News monitoring: find recent articles on a topic with specific framing
Academic research: find PDF papers on a subject
Academic research: find PDF papers on a subject