Boolean Logic & Phrase Operators
Search Techniques
Chapter 2 · Boolean Logic & Phrase Operators
searchtech1-1 ended with a plain, unstructured query — python list sort error — as the example of what most people actually type. This chapter turns that same query into four progressively more deliberate ones, using nothing but plain-text operators typed directly into the search box. No special tool, account, or settings page is required for any of them.
The Default: Implicit AND
Type multiple words into a search box and, without asking for it, you get an implicit AND: the engine favors pages containing all of the terms. python list sort error is silently treated as python AND list AND sort AND error — nobody types the word AND, but it's the operator doing the work by default.
OR — Deliberately Broadening a Query
Where AND narrows, OR broadens: it asks for pages matching either term, not necessarily both. This matters most when a concept has more than one common name and searching for just one misses pages that only use the other.
| Query | What it asks for |
|---|---|
python list sort error | Pages containing all four words (implicit AND) |
python list sort error OR exception | Pages containing "error" or "exception" — catches pages that describe the same problem using different terminology |
or is just another ordinary keyword to most search engines, folded into the implicit AND like any other word. Only the capitalized OR is recognized as the Boolean operator — this is one of the few places search-engine syntax is genuinely case-sensitive.
The Minus Operator — Excluding a Term
A minus sign placed directly before a word excludes results containing that word — the closest thing a search engine offers to a Boolean NOT. The classic example: jaguar -car favors the animal over the car brand, without having to describe what is wanted, only what isn't.
jaguar -car excludes "car." jaguar - car — with a space after the minus — is parsed as three separate words, and the dash is ignored as punctuation rather than treated as an operator. This is the single most common way this operator silently fails to do anything at all.
Exact-Phrase Quoting
Wrapping words in double quotes forces a literal, in-order phrase match rather than a loose collection of individual words. "list index out of range" favors pages containing that exact four-word sequence, rather than pages that merely happen to contain "list," "index," "out," "of," and "range" scattered anywhere on the page.
Combining All Four in One Query
"list index out of range" python -django OR flask — an exact-phrase error message, implicitly ANDed with "python," explicitly excluding "django," with an OR broadening the framework term to also match "flask." Every operator covered in this chapter is present in that single line.
A Deliberate Point of Confusion: This Is Not Regex
regex1 covers a completely different system, and the surface-level similarity between the two — both use short, symbolic characters typed inline — makes them genuinely easy to conflate if the distinction is never stated outright.
| Search-engine operators (this chapter) | Regex (regex1) |
|---|---|
| Signals sent to a search engine's own query parser, interpreted against a pre-built index | A pattern-matching language interpreted directly against literal text/strings by a program (grep, sed, a regex engine in code) |
A small, fixed set of operators (OR, -, "...", and a handful more covered in later chapters) | A large, composable grammar — character classes, quantifiers, anchors, groups, backreferences |
| Whole-word/whole-phrase presence or absence — no character-level matching | Matches at the character level — can match part of a word, a numeric pattern, or arbitrary structure |
* inside a quoted phrase as a wildcard standing in for "any one word" — "the * theory of relativity" could match "the special theory of relativity" or "the general theory of relativity." That looks exactly like regex's own *, but regex's * means something entirely different: "zero or more of the immediately preceding character." Same symbol, two unrelated meanings, in two systems this course and regex1 each cover separately — worth remembering precisely because the symbol is identical.
Hands-On Exercises
A colleague writes the query react hooks - useEffect expecting it to exclude pages about useEffect, but the results still include plenty of useEffect content. Explain exactly why, using this chapter's own material.
Write a single compound query that looks for the exact phrase "connection refused," requires the word "postgres," and broadens to also match either "docker" or "kubernetes." Explain what each part of your query is doing.
📄 View solutionExplain precisely why search-engine query operators and regex are easy to conflate despite being genuinely different systems, and give one concrete example (beyond the asterisk) where treating them as the same thing would lead someone astray.
📄 View solutionChapter 2 Quick Reference
- Implicit AND — multiple words default to "must contain all of these"
- OR (capitalized) — broadens to "contains either of these"
-term(no space after the minus) — excludes results containing that term"exact phrase"— forces a literal, in-order match instead of a loose word collection- Search-engine operators and regex look similar but are genuinely different systems — the same symbol (
*) can mean two unrelated things in each - Next chapter: Site & Domain Scoping