What is Boolean search? It's a technique for controlling exactly what a search returns: you combine keywords with operators AND, OR, and NOT to narrow, broaden, or filter search results. It’s named after George Boole, the 19th-century mathematician who built a system of logic around true and false.
Whether you’re an ecommerce shopper, scientific researcher, or recruiter, Boolean search checks each result against your search conditions and only returns the ones that come back true—does this result contain "running" AND "shoes," yes or no? Those three operators—AND, OR, and NOT—are the building blocks of Boolean logic, and each handles the true-false answers with its own rule: require all, require any, or rule one out.
Key takeaways
- Boolean search combines keywords with three operators—AND, OR, and NOT—to narrow, broaden, or filter exactly what a search returns.
- The foundation of Boolean search: AND requires every term, OR accepts any term, and NOT excludes terms you don’t want.
- Behind the scenes, Boolean search checks each result against your terms as true or false, then keeps the ones that fit the operators you use.
- The payoff of using Boolean search is precision: you describe your need once, instead of sifting irrelevant results by hand.
- The same logic powers databases—MongoDB's Query API uses Boolean operators to filter documents, and MongoDB Search adds relevance ranking on top.
Table of contents
- The three Boolean operators: AND, OR, and NOT
- Are there more Boolean operators besides AND, OR, and NOT?
- Boolean search modifiers: Quotation marks, parentheses, and wildcards
- How does Boolean search produce the results you expect?
- How does Boolean search work in MongoDB?
- Where is Boolean search used?
- What are common Boolean search mistakes?
- What's ahead for search?
- Related resources
- FAQs
The three Boolean operators: AND, OR, and NOT
Boolean search runs on three operators: AND, OR, and NOT. Each one tells the system what to do with the specific search terms you type. Put AND between your terms and every term becomes a requirement—a result has to include them all. Put OR between them and each becomes an option—a result only needs one. Put NOT before a term and the system drops any results that contain it.
In most search engines, you must capitalize all three for Boolean search to work. Otherwise, a lowercase "and" reads as just another search word; the capital letters are what tell the search engine it's an operator.
Are there more Boolean operators besides AND, OR, and NOT?
Yes, there are a few more Boolean operators beyond AND, OR, and NOT, but they’re more specialized. The main ones are proximity operators—NEAR, ADJ, SAME, and W/n—most often used in legal and academic databases, not everyday search engines.
Boolean search modifiers: Quotation marks, parentheses, and wildcards
Beyond the operators, three more elements—called modifiers—fine-tune a search. They tell the system how to read your keywords:
Quotation marks lock keywords into an exact phrase: “running shoes” finds the two words together, in order, instead of every result that mentions running and shoes separately.
Parentheses group terms so the system does the math within them first: (trail OR road) AND waterproof returns either kind of shoe, as long as it’s also waterproof.
Wildcards stretch one term to catch its variations: run* returns run, running, runner, and runners.
BOOLEAN SEARCH IN RECRUITING
A recruiter searching résumés might type:
(developer OR programmer) AND Python NOT intern
The parentheses tell the system to find developers OR programmers first. From there, AND keeps only the ones who also list Python, and NOT drops anyone marked intern—narrowing thousands of profiles down to the right candidates.
How does Boolean search produce the results you expect?
Now you know how to write a Boolean search. But what is Boolean search doing when you hit “Enter”? It's searching an inverted index—the structure behind keyword search that maps each search word to all the records that contain it.
If you search for waterproof AND leather, the system doesn’t scan every record or document looking for those words. Instead, it pulls up two ready-made lists—everything tagged waterproof, and everything tagged leather—and each operator combines the lists differently:
Waterproof AND leather keeps only the products found on both lists.
Waterproof OR leather keeps anything on either list.
Waterproof NOT leather includes anything tagged waterproof and excludes anything tagged leather.
When a Boolean search is not used, waterproof leather finds anything tagged exactly with “waterproof leather” in sequence.
BOOLEAN SEARCH IN SCIENCE
A researcher searching a science literature database might type:
Salmonella AND (resistance OR AMR) NOT review
The AND requires both Salmonella and resistance, the OR also pulls in papers that use the abbreviation AMR, and NOT removes review articles, surfacing the primary studies out of millions of papers.
Does Boolean search rank results?
No, a Boolean search doesn’t rank results. A result either qualifies or it doesn’t. A plain Boolean search asks one question—does this match, yes or no?—and only returns the results that qualify. That’s the tradeoff of Boolean search: it’s fast and exact, but it can’t tell you which individual result is the best match.
Modern search adds that missing layer. On top of the same Boolean logic, it scores how well each result fits and delivers the strongest matches first, transforming a list of simple matches into a ranked list. That’s where MongoDB comes in.
How does Boolean search work in MongoDB?
MongoDB runs Boolean search through two tools: the Query API, which returns a list of matches, and MongoDB Search, which returns a ranked list.
The examples in this section focus on MongoDB’s logical query operators—the pieces that map cleanly to AND, OR, and NOT. The full MongoDB Query API includes many more operators for comparisons, geospatial queries, arrays, and more; for the complete list, see Query Predicates documentation.
The Query API: Boolean operators
The Query API is Boolean at its core and searches MongoDB directly. It checks each document against your conditions and returns the ones that qualify, without ranking them.
The three operators (AND, OR, and NOT) show up in MongoDB, but it calls them logical operators and writes them with a $ prefix. For example, AND becomes $and—but you rarely need to type it because when you put two conditions together, MongoDB applies AND on its own. OR becomes $or.
To exclude, MongoDB uses $ne to rule out a value or $nor to rule out a set. MongoDB has a $not too, but it negates another operator instead of working alone, which is why $ne and $nor do most of the exclusion work.
Syntax comparison: Plain text vs. MongoDB Query API
Here is how a standard keyword search string translates into a professional MongoDB database query:
Plain text Boolean:
Plaintext
MongoDB Query API syntax:
JavaScript
MongoDB Search: Boolean, plus ranking
MongoDB Search keeps the Boolean logic found in the Query API but adds ranking. It uses an inverted index—the structure from the section above—and scores each result by relevance, so the closest matches come back first.
It doesn’t use $and and $or. Instead, it combines conditions with a compound operator built from named clauses:
must: Works like AND. The condition has to match, and it counts toward the relevance score.
should: Works like OR. The condition isn’t required, but matching it pushes the relevance score higher.
mustNot: Works like NOT. The condition can’t match.
filter: Works like AND, but doesn’t affect the relevance score. Use it when you want to narrow results without changing the ranking.
So a search for waterproof leather shoes might require waterproof (must) and prefer leather (should). Every result is waterproof, and the leather ones rise to the top.
See the full list of Query API functionality.
BOOLEAN SEARCH IN HEALTHCARE
A care team might query patient records for diabetes AND (high A1C OR high glucose) NOT insulin—finding patients whose blood sugar is poorly controlled but who aren’t on insulin yet.
Where is Boolean search used?
Boolean search shows up anywhere you need to narrow down a large set of results.
Search engines
You’ve probably typed two words into the search bar in Google. When you do this, Google looks for pages with both of your terms—it applies AND on its own, the same way MongoDB does. When you add quotation marks to a phrase, the search engine will return results for that phrase only. Add a minus sign in front of a word, and Google makes sure it isn’t included in the search results (Google’s version of NOT). Type OR in capitals between two words, and Google returns pages that contain either one. The Google operators look a little different from AND, OR, and NOT, but the Boolean logic underneath is the same.
Recruiting
In recruiting, Boolean search is a daily, named skill used in candidate searches. A single role can draw far more résumés and profiles than anyone could read by hand, so precision isn't a nicety—it's required. A well-built search string combines keywords—job titles and specific skills—with terms to exclude, separating the candidates who fit from the ones who don't. That precision is why human resources teams treat Boolean search as a core skill, and why it shows up by name in recruiter job postings and sourcing training.
BOOLEAN SEARCH IN LAW
A lawyer researching a slip-and-fall case might search:
negligence AND (premises OR property) NOT criminal
This pulls relevant civil cases about unsafe premises, while leaving out criminal matters that share the same language.
What are common Boolean search mistakes?
Boolean search is precise, which means it relies on precise search terms, too. If you type something incorrectly in the search field, those small errors can change what comes back.
Mistakes typically come up in predictable ways:
Using lowercase operators: If you type “and,” “or,” or “not” in lowercase, many search engines read them as ordinary search terms instead of commands. Capitalizing them is what marks them as operators—which is why AND, OR, and NOT are always written in caps.
Skipping parentheses: Without grouping the words you want searched together, the search engine decides the order of operations for you: running OR trail AND waterproof can return results you didn’t expect. When you enter (running OR trail) AND waterproof, it makes your search preferences clear.
Excluding too much with NOT: When you use NOT in front of a term, it drops every result containing that term. It might even drop results you actually wanted. If you exclude “junior” to filter out junior developers, it can also drop a senior developer whose profile mentions mentoring juniors. Because of this, it’s a good idea to use it sparingly. If you do use it, double-check what it’s excluding.
Stacking too many ANDs: Since each AND narrows the results further, if you add too many, it may narrow the results down to nothing. If a search comes back empty, removing an AND or swapping it out for an OR usually helps.
Forgetting quotation marks: If you search for exact phrases without inserting quotes, the search engine looks for each of the words separately, anywhere in the document. When you need to find a phrase exactly as you typed it, you need to add quotation marks—”machine learning” instead of machine learning.
What's ahead for search?
Search keeps getting smarter. Newer approaches like semantic and vector search go beyond matching exact words to understanding what a query means—so a search for "running shoes" can surface "trail sneakers" even without a shared keyword. But Boolean search isn't going anywhere. Those systems still need a way to filter precisely—to require, exclude, and narrow on exact values—and that's the job the three operators do.
The newest search combines both: Boolean logic for precision, semantic ranking for meaning. In MongoDB, that's MongoDB Search and Vector Search working side by side. The three operators Boolean search uses aren't relics—they're the foundation the smarter layers build on.
Related resources
- Full-Text Search: What It Is and How It Works — Learn how databases search the full contents of your documents to surface relevant matches.
- What Is Semantic Search? — See how search moves beyond keywords to understand the meaning behind a query.
- What Is Vector Search? — Explore how storing data as vectors lets you search by similarity and meaning.
- MongoDB Search — See search layers relevance ranking on top of Boolean logic in your MongoDB data.